Temporal Dead Zone Quiz
Question
What happens when you access a `let` variable before its declaration line?
Hint
let and const are hoisted but not initialized before their line.
Explanation
let and const declarations are hoisted to the top of their block, but they remain in the 'temporal dead zone' (TDZ) until the actual declaration line. Accessing them during the TDZ throws a ReferenceError. This is different from var, which is initialized to undefined when hoisted.
Related Resources
Related Lessons
- JavaScript Variables
Learn about the temporal dead zone.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.