1. Syntax
Basic ecmascript concepts:
BytesCase Sensitive. Variables, function names, operators, and everything are case sensitive.
BytesThe variable type is weak.. Variables in ecmascript do not have a specific type. when defining a variable, you only need to use the VaR operator to initialize the variable to any value. You can change the type of data stored in the variable at any time.
BytesThe semicolon at the end of each line is optional. Ecmascript allows developers to determine whether to end a row with a semicolon.Code. If there is no semicolon, ecmascript regards the end of the line of code as the end of the statement, provided that the meaning of the Code is not broken. The best way to write code is to always add a semicolon without a semicolon. Some browsers may not be able to run correctly.
BytesNote. Ecmascript has two types of Annotations: single-line and multi-line annotations. A single line comment starts with //. A multi-line comment starts with/* and ends.
BytesParentheses indicate code blocks. A code block indicates a series of statements that should be executed in sequence. These statements are encapsulated between {And.
2. Variables
Variables in ecmascript use the VaR operator and variable name definition. You can use the VaR statement to define one or more variables. Variables in ecmascript do not need to be initialized.
Developers should develop good programming habits. Although javascript can assign multiple data types to a variable, this method is not recommended.When using a variable, the same variable should only store one data type.
Two rules for variable names:
The first character of the period must be a letter, underscore (_), or dollar sign ($)
The remaining characters of the delimiter can be any character.
The secret variable name cannot be a keyword or reserved word.
Camel markup-the first letter is lowercase, And the next words start with an uppercase letter.
◊ Pascal markup-the first letter is in upper case, and the subsequent words start with an upper letter.