Introduction to JavaScript
What is JavaScript?
#What is JavaScript?
JavaScript is a small, lightweight, object-oriented, cross-platform client-side scripting language.
JavaScript is embedded into the browser software. As long as your computer has a browser, you can execute the JS program.
JavaScript is an object-oriented programming language.
# In a program, objects are composed of "properties" and "methods".
In reality, boyfriend and girlfriend are just an "object". "Things" are "objects". An "object" is an "object".
"Object" has various characteristics (attributes), such as: name, height, weight, age, etc.
"Object" has many methods. What can the object "human" do? Or "human behavior." Such as: go to work, go hiking, go traveling, etc.
Note: As long as you can use the objects in JS, we don’t need to develop the objects ourselves.
Cross-platform: JS programs can run on multiple platforms, such as: windows, linux, mac, IOS, etc.
Client-side script program: JS can only be run on the client's browser, not on the server.
The browser is a translator that can translate three types of codes: HTML code, CSS code, and JavaScript code.
What can JavaScript do?
Form validation: It is the most basic function of JS.
Dynamic HTML: can achieve some dynamic and repetitive effects.
Interactive: Human-computer interaction, interacting with elements in the web page through the keyboard or mouse.
The origin of JavaScript’s name?
JavaScript was originally called "LiveScript" and was a client language developed by Netscape for its browser Navigator 2.0.
I wanted to take advantage of the fame of Java to grow quickly, so I changed its name to JavaScript.
As they hoped, JavaScript finally did take off
<script></script>Mark
JS code is also embedded in the HTML document.
The same web page can have HTML code, CSS code, and JavaScript code.
Introduce JS program code through<script></script>
Example
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>php.cn</title> <script type="text/javascript"> window.alert("欢迎大家学习我们的JavaScript课程,一分耕耘一分收获,希望大家多多练习代码"); </script> </head> <body> </body> </html>
Comments in JS
By the way, let’s summarize the other two comments on the page
- ##HTML comments: <!—Comment content-->
- CSS comments: /* Comments*/
- JavaScript comments: // or /* Multi-line comments*/
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>php.cn</title> <script type="text/javascript"> //在当前窗口弹出以一个对话框 window.alert("欢迎大家学习我们的JavaScript课程,一分耕耘一分收获,希望大家多多练习代码") </script> </head> <body> </body> </html>