Skip to main content
Practice Problems

What is temporal dead zone (TDZ) in JavaScript

What is Temporal Dead Zone (TDZ)?

TDZ (Temporal Dead Zone) is the time period between the start of a variable's scope (e.g., if block, for, function, etc.) and its actual initialization, during which the variable cannot be accessed.

This zone occurs when using let or const.


Simple Example

javascript
console.log(x); // ❌ ReferenceError: Cannot access 'x' before initialization let x = 10;

Although variable x is declared, you get an error because you accessed it before initialization — you're in the temporal dead zone.

TDZ applies to:

  • let
  • const
  • Function parameters with destructuring
  • Classes declared via class

Conclusion

Variable TypeHoistedInitializedTDZ Exists
varYesundefinedNo
letYesNoYes
constYesNoYes
Important:

TDZ is the reason why let and const are safer than var: you cannot use variables before they're declared, and this prevents errors.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.

Finished reading?
Practice Problems