Simply put, the identifier naming rules are as follows:
The first character can be any Unicode letter, and a dollar sign ($) and an underscore (_).
The second and subsequent characters can also be used as numbers.
These are all valid identifiers.
arg0
_tmp
$elem
Pi
The following are illegal identifiers.
1a
23
***
A+b
-D
Chinese is a valid identifier and can be used as a variable name.
var temporary variable = 1;
JavaScript has some reserved words that cannot be used as identifiers: arguments, break, case, Catch, class, Const, continue, debugger, default, delete, do, else, enum, Eval, export, extends, false, finally, for, function, if, implements, import, in, instanceof, interface, let, new, NULL, Package, private, protected, public, return, static, super, switch, this, throw, true, try, typeof, Var, void, while, with, Yield
In addition, there are three words, although not reserved words, which, because of their special meaning, should not be used as identifiers: Infinity, NaN, undefined.
The part of the source that is ignored by the JavaScript engine is called a comment, and its role is to interpret the code. JavaScript provides two kinds of annotations: one is a single-line comment, with//head, and the other is multiline comment, placed between/* and/*.
This is a single-line comment
/*
This is
MultiRow
Comments
*/
The code section later in this tutorial uses both forms to illustrate the results of your code and what you need to be aware of.
In addition, because of historically JavaScript-compatible comments for HTML code, <!--and--> are also treated as single-line annotations.
x = 1; <!--x = 2;
--> x = 3;
In the code above, only x = 1 is executed, and the rest is commented out.
Note that,--> is treated as a single-line annotation only at the beginning of the line, otherwise it is an operator.
function countdown (n) {while
(n--> 0) Console.log (n);
}
Countdown (3)
//2
//1
//0
In the code above, n--> 0 is actually treated as n--> 0 because the output is 2, 1, and 0.
The above is a small series for everyone to bring the cliché JavaScript variable naming norms and comments of the entire content, I hope to help you, a lot of support cloud Habitat Community ~