Temporal Dead 区域测验
单选题 中等
题目
什么 happens 当你 access `let` 变量之前它的 declaration 行?
提示
let and const 是 hoisted 但不 initialized 之前它们的行.
解释
let and const declarations 是 hoisted 到顶部的 它们的块, 但它们 remain in 'temporal dead 区域' (TDZ) 直到实际 declaration 行. Accessing 它们期间 TDZ throws ReferenceError. 这个是 不同从 var, 哪个是 initialized 到 undefined 当 hoisted.
相关资源
相关课程
- JavaScript 变量
学习关于 temporal dead 区域.
查阅不认识的术语
新手友好的术语表用大白话解释编程术语——变量、函数、DOM、Promise 等等。
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。
动手做项目
通过引导式项目应用所学,含起始代码与解决方案。