1. Character Set
The JavaScript program is written in Unicode (two-byte notation) character set.
2. Case-sensitive
JavaScript is a case-sensitive language. HTML is case-insensitive, due to the fact that the two are closely related and differentiated.
3. Spaces and newline characters
JavaScript ignores spaces between program identifiers, and in most cases, line breaks are ignored.
4. Comments
JavaScript supports annotations in two formats.
Single-line Comment://comment Content
Multiline Comment:/* Comment Content Comment content */
Two multiline annotations cannot be nested.
5. Direct volume
The so-called direct volume is the data value that is used directly in the program.
1.2//Number
' Adsa '//String
True//Boolean value
/javascrpt/gi//Regular expression Direct volume,
NULL//NULL
{x:1,y=2}//Object
[1,2,3,4]//array
6. Identifiers
An identifier is a name used to name a variable or function.
Identifiers in JavaScript must begin with a letter, underscore, or $, and subsequent characters can be letters, numbers, line breaks, or dollar symbols, and numbers cannot appear as the initials of an identifier.
7. Reserved words
JavaScript takes some identifiers and uses them as their own keywords, so you can no longer use them as identifiers in your program.
Keywords that have been used are:
Note: If you use a keyword as a variable name or function name, you might get an error message such as "Identifier expected" (there should be an identifier, an expected identifier).
Reserved words that are not used but are not recommended:
Note: If you use a reserved word as a variable or function name, you will likely not receive any error messages unless the reserved word is implemented by the future browser. When the browser implements it, the word is treated as a keyword, so a keyword error occurs.
The specific implementation of JavaScript may define unique global variables and functions, and each specific Javascrip runtime environment (client, server side) has its own global properties, a list of functions. JavaScript pre-defines a number of global variables and functions and should avoid using their names as variable names and function names.
Global functions
Global variables:
In JavaScript implementations that allow scripting Java through LiveConnect or related technologies, global objects are given the Java and package properties listed here and the GetClass () method
8. Optional semicolon
Javascrip use semicolons to separate statements, and you can usually omit semicolons between statements if the statement is exclusive to a single line.
a=3;b=4;
Equivalent to
A=3
B=4
JavaScript does not fill the semicolon at all line breaks (so most of the time the newline character is ignored), and JavaScript fills the semicolon only if the code is not parsed correctly when the semicolon is missing.
var a
A
=
3
Console.log (a)
resolves to var a;a=3;console.log (a) because the code cannot be parsed without adding a semicolon.
and
var y=x+f
(a+b). ToString ()
will be parsed into Var y=x+f (a+b). toString ();
If the current statement and the next line of statements cannot be parsed, JavaScript fills the semicolon after the first line, which is a general rule, but there are two unexpected
1, return, break and continue immediately after the line, JavaScript will fill in the line at the semicolon;
Return
True
will be parsed into return; True
2, + + and--operators
If, as a suffix expression, he and the expression should be on one line, the row bit will fill the semicolon, and the + + will parse with the next line
X
++
Y
Will parse into x;++y;
The lexical structure of JavaScript