AceDevHub
Beginner JavaScript Interview QuestionsBeginnerConcept

JavaScript · Question 8

What is the Temporal Dead Zone (TDZ) in JavaScript?

Direct answer

The Temporal Dead Zone is the period after entering a scope but before a let, const, or class binding is initialized; accessing that binding during this period throws a ReferenceError.

The TDZ begins when execution enters the relevant scope and ends when the declaration is evaluated. The binding exists, but it is not yet initialized.

For example, { console.log(user); let user = 'Ada'; } throws a ReferenceError. This is different from var, which is initialized to undefined before execution reaches its declaration.