2.1 syntax
Case-sensitive, weak variable type, line-and-tail semicolons are optional, comments are double-slashes, and parentheses indicateCodeBlock
2.2 Variables
Variables are declared using VAR. Naming rules for variables: the first character must be a letter, underline, or dollar sign; the remaining characters can be an underscore, dollar sign, or any letter or digit.
Variable naming rules:
camel Tag Method : lowercase letter. The following words start with an uppercase letter. For example, VAR m Y T est v alue = 0, m Y S econd T est v alue =" hi ";
Pascal Markup: The first letter is capitalized, And the next word starts with an uppercase letter. For example: VaRMYTESTVAlue = 0,MYSEcondTESTVAlue = "hi ";
Hungary type labeling: Append a lower-case letter (or lower-case letter sequence) to a variable named by the Pascal mark, indicating the type of the variable. For example, I represents an integer, and s represents a string, as shown below:
VaRImYTESTVAlue = 0,SmYSEcondTESTVAlue = "hi ";
The prefix used to define ecmascript variables using the Hungary type markup method is as follows:
Type: array Prefix: A Example: avalues
Type: Boolean Prefix: B example: bfound
Type: Floating Point Prefix: F example: fvalue
Type: function Prefix: FN example: fnmethod
Type: integer Prefix: I example: ivalue
Type: Object Prefix: O example: otype
Type: Regular Prefix: re example: repatten
Type: String Prefix: s example: svalue
Type: Variable Prefix: V example: vvalue
2.3 keywords
The ECMA-262 defines the Keyword:
Break case catch continue default Delete do else finally for function if in instanceof new return switch this throw try typeof var void while
2.4 Reserved Words
Reserved Words in ECMA-262 3rd edition:
Abstract Boolean byte char class const debugger double Enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile
2.5 Original Value and reference value
The original value is a simple data segment stored in the stack, that is, their values are directly stored in the access location of the variable.
Reference value is an object stored in heap. That is, the value stored in a variable is a pointer to the memory of the object.