1.let command
1) Basic usage
The Let command is a new command for declaring a variable, similar to Var, but the ES6 variable is valid only within the code block where the Let command resides.
2) "Declaration in advance" does not exist
Let declaration of the variable does not exist "declaration in advance", the variable must be used after the declaration, otherwise it will cause an error, for example:
Console.log (a); // undefinedconsole.log (b); // Error! var a=3;let b=3;
3) Temporary Dead Zone
Whenever a let command exists within a block-level scope, the variable it declares binds to the current block-level scope and is unaffected by the external:
1 var tmp=123; 2 3 if (true) {4 tmp= "abc" ; Error! 5let tmp; 6 }
4) Duplicate declarations are not allowed
The Let command does not allow the same variable to be declared repeatedly within the same scope
Let and const commands in ES6