var & let

  let是局部变量,下例中,let不能换成var.

  var & let & const

  var是全局或函数级变量,下图可看出区别。

  var & let & const

  let无法在全局定义变量。

  同一block内,不能得定义同名let 变量。

  var & let & const

  Temporal dead zone

  var & let & const

  switch算一个block

  var & let & const

  let与for

  var & let & const

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

相关文章:

  • 2021-08-19
  • 2022-02-03
  • 2022-01-01
  • 2022-02-27
  • 2022-12-23
  • 2021-05-09
猜你喜欢
  • 2022-01-21
  • 2022-12-23
  • 2021-04-22
  • 2022-12-23
  • 2021-05-07
  • 2021-11-10
  • 2021-07-23
相关资源
相似解决方案