identifiers
- first character, can be any Unicode letter (including letters in English letters and other languages), as well as the dollar sign (
$
" and underscores (_
".
- The second and subsequent characters, in addition to Unicode letters, dollar signs, and underscores, can also be numbered
0-9
.
JavaScript has 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
Source: http://javascript.ruanyifeng.com/grammar/basic.htmlThere are three more words that are not reserved words, but should not be used as identifiers because they have special meanings:
Infinity
,
NaN
,
undefined
.
The traversal of a class array object can be done using the same method as the traversal of a group object . JS User Custom Error
The following example fully reflects the try...catch...finally
order of execution between the three.
function F() { Try { Console.Log(0); Throw ' Bug '; } Catch(e) { Console.Log(1); return true; //This sentence would have been deferred until finally the end code block was executed Console.Log(2); //will not run } finally { Console.Log(3); return false; //This sentence will overwrite the previous return Console.Log(4); //will not run } Console.Log(5); //will not run}var result = F();//0//1//3result//False
In the above code,catch
Before the code block finishes executing, it executes thefinally
code block. Fromcatch
Intofinally
The logo, not only hasreturn
Statement, andthrow
Statement.
function F() { Try { Throw ' something went wrong! '; } Catch(e) { Console.Log(' Snap to internal error '); Throw e; //This sentence would have waited until finally ended and then executed } finally { return false; //Direct return }}Try { F();} Catch(e) { //Does not execute here Console.Log(' caught outer ' bogus ');}//Snap to internal error
In the code above, entercatch
After the code block, one encountersthrow
Statement, it will executefinally
Code blocks, which havereturn false
statement, so it is returned directly, and will no longer go back to executioncatch
The remainder of the code block.
Source: http://javascript.ruanyifeng.com/grammar/error.html
From for notes (Wiz)
JavaScript Basic Syntax