Temporal Dead Zone
Definition
The period between entering a scope and the point where a `let` or `const` variable is declared. Accessing the variable during this period throws a ReferenceError. This prevents bugs caused by using variables before they are initialized.
Code Example
Learn More
Related Terms
A named container that stores a value in memory. JavaScript uses let, const, and var to declare variables. let and const are block-scoped, while var is function-scoped.
HoistingJavaScript's behavior of moving variable and function declarations to the top of their scope before code execution. var declarations are hoisted and initialized to undefined, while let and const are hoisted but not initialized (temporal dead zone).
ScopeThe region of code where a variable is accessible. JavaScript has global scope, function scope, and block scope. Block scope was introduced with let and const in ES6.