Problem Statement
What is the temporal dead zone (TDZ)?
Explanation
In JavaScript, the Temporal Dead Zone (TDZ) is:
The time between entering a scope and the actual line where a let or const variable is declared, during which you cannot access that variable.
Even though let and const are hoisted, they are not initialized until their declaration is executed.
If you try to use them before that point, you get a ReferenceError, not undefined.
Code Solution
SolutionRead Only
console.log(x); // ❌ ReferenceError: Cannot access 'x' before initialization let x = 10;
Practice Sets
This question appears in the following practice sets: