InterviewSolution
Saved Bookmarks
| 1. |
What is a Temporal Dead Zone? |
|
Answer» Variable Hoisting does not apply to LET bindings in ES6, so let declarations do not RISE to the top of the current execution CONTEXT. A ReferenceError is thrown if the variable in the block is referenced before it is INITIALIZED (unlike a variable declared with var, which will just possess the undefined value). From the beginning of the block until the initialization is performed, the variable is in a "temporal dead zone." console.log(a); // undefinedconsole.log(b); // causes ReferenceError: aLet is not definedvar a = 1;let b = 2; |
|