The syntax in JS is heavily borrowed from C and other Class C languages (Java,perl).
Everything in JS (variables, function names, operators, etc.) are case-sensitive. such as "Var A;" Variable A with "Var A;" In the Variable a differs in the. Typeof,valueof,instanceof and so on are case-sensitive.
The naming rules for identifiers (variables, function names, parameter names, and so on) in JS: Hump naming style. The first character cannot be a number, it can be a letter, an underscore, a $ symbol, and other characters can be numbers, letters, underscores, and $.
JS code Comment://single-line comment,/** code block **/multiline Comment
The identifier in JS cannot be the same as the keyword. For example, if you define a variable or function, the name cannot be typeof, because TypeOf is the key word in ES;
Variable: The variable in JS is loosely typed (meaning that the variable in JS can hold any type of value). Each variable is just a placeholder for a saved value.
Variable declaration method: var variable name;
Note: variables defined with the VAR operator will become local variables that define the scope of the variable.
For example, you define a variable at the beginning of a JS file (and outside the function): var first = 1; then this variable first is the local variable of the entire JS document, and the variable is automatically destroyed when the entire document is executed;
Again such as:
function f () {var first = 1;}
Then this variable first is a local variable in the scope of the function f (), and when the function f () is executed, the variable is automatically destroyed.
You can also omit the operator Var to create a global variable. (This is not recommended, because defining global variables in local scopes is not easy to maintain)
function f () {first = 1;}
In this notation, the variable first is a global variable. Outside of the function, you can still access the variable.
Note: "What is a scope?" will be explained later. "and" JS garbage collection mechanism. "
Basic JavaScript Concepts