ES6规定,let和const定义的变量在可访问前有两个步骤:
先在作用域被创建(不可访问即——没有变量提升)
后进行词法绑定
从变量在作用域中被创建到可以访问着一段时间称为暂时性死锁。
eg1,
console.log(a) // ReferenceError: a is not defined
let a
eg2.
typeof a // ReferenceError: a is not defined
let a
ES6规定,let和const定义的变量在可访问前有两个步骤:
先在作用域被创建(不可访问即——没有变量提升)
后进行词法绑定
从变量在作用域中被创建到可以访问着一段时间称为暂时性死锁。
eg1,
console.log(a) // ReferenceError: a is not defined
let a
eg2.
typeof a // ReferenceError: a is not defined
let a