JavaScript is an object-and event-driven scripting language, mainly used on clients. JavaScript Overview
JavaScript is an object-and event-driven scripting language, mainly used on clients.
Features:
1. Interaction (what it can do is the dynamic interaction of Information)
2. Security (direct access to the local hard disk is not allowed)
3. cross-platform (any browser that can interpret Js can execute and has nothing to do with the Platform)
JavaScript is different from Java
1. JS is a product of Netscape, and its predecessor is LiveScript. Java is a product of Sun and is now a product of Oracle.
2. JS is based on objects and Java is object-oriented.
3. JS can be executed only after explanation. Java needs to be compiled into a bytecode file before execution.
4. JS is weak type, and Java is strong type.
JavaScript syntax
Each language has its own syntax rules. JS syntax is similar to Java, so it is easier to learn. JS also contains common language components such as variables, statements, functions, and arrays.
1. Variables
The keyword var is used to define the weak type. You do not need to specify a specific data type.
For example, var x = 3; x = "hello ";
Note: The Special constant value in JS is undefined. It is used when the variable is not initialized. The value of this variable is undefined (undefined ).
Note: Javascript statements can end at the end without a semicolon. They are not strictly linguistic.
However, to comply with programming specifications, the Terminator must be defined Like java.
In some cases, you must write a semicolon, for example, var x = 3; var y = 5. If the two statements are written in the same row, they must be separated by semicolons.
1) KEYWORDS: almost the same as Java
2) identifier, separator: Same as Java
3) Note: The two types in Java are used: // and /**/
4) Data Type: number, string, boolean, and undefined (when the variable is declared but not assigned a value)
5) variable: var (weak type, similar to the Object in Java)
6) in js, single quotes and double quotation marks are the same, and they are encapsulated as strings (but they are enclosed in two quotation marks at the same time, and the internal quotation marks must be single quotes)
7) global variables and local variables
Global variables-as long as they are not declared inside the function, they are all. It will not be distinguished by braces or scripts.
A. As long as it is not declared inside the function, a variable is also valid in the page script even if it is declared in the imported. js file.
B. The scope of variables in Java is distinguished by braces, whereas JS is not.
Local variable ---- the sum parameter declared inside the Function
The parameter inside the function is also local, and the changed value can only be valid internally. The parameter is invalid after the function is returned.
Example:
Javascript Language Learning