statements in ECMAScript is terminated by a semicolon, though omitting the semicolon makes
The parser determine where the end of a statement occurs, as in the following examples:
var sum = a + b //valid even without a semicolon-not recommendedvar diff = b; Valid-preferred
even though a semicolon is no required at the end of statements, it's recommended to always
Include one.Including semicolons helps prevent errors of omission, such as not finishing what are you
Were typing, and allows developers to compress ECMAScript code by removing extra white space
(Such compression causes syntax errors when lines does not end in a semicolon). Including semicolons
Also improves performance in certain situations, because parsers try to correct syntax errors by
Inserting semicolons where they appear to belong.
For example, the following code:
"Use strict" function f (A, B) { return a | b;} Console.log (f (2, 1));
Output:
So, let's not let the parser guess our intentions, after all, the parser is not artificial intelligence:
Correct wording:
The necessity of a semicolon for JavaScript statements