【var & let】
let是局部变量,下例中,let不能换成var.
var是全局或函数级变量,下图可看出区别。
let无法在全局定义变量。
同一block内,不能得定义同名let 变量。
Temporal dead zone
switch算一个block
let与for
【const】
Constants are block-scoped, much like variables defined using the let
statement. The value of a constant cannot change through re-assignment, and it can't be redeclared.
参考:
1、https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let
2、https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const