Tekkaman

导航

 

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

posted on 2016-02-23 13:39  Tekkaman  阅读(282)  评论(0编辑  收藏  举报