//Version A: var let = true; console.log(let);//true
Because the specification says so.
From https://www.ecma-international.org/ecma-262/6.0/#sec-let-and-const-declarations-static-semantics-early-errors:
13.3.1 Let and Const Declarations 13.3.1.1 Static Semantics: Early Errors LexicalDeclaration : LetOrConst BindingList ; It is a Syntax Error if the BoundNames of BindingList contains "let".
LexicalDeclaration : LetOrConst BindingList ;
:
;
"let"
The variable statement specification has no such limitation, probably because let was not in use at the time var was defined, and changing the specification for var would be a breaking change.
let
var
1.4m articles
1.4m replys
5 comments
57.0k users