Interview Question

What is temporal dead zone?

Lexical bindings cannot be accessed before initialization.

💡 Concept ✅ Quick Revision ⚡ JavaScript

Answer

The temporal dead zone is the period when a lexical binding exists but is not initialized. • It begins when the scope is entered and ends when the declaration is evaluated. • Reading the binding during this period throws ReferenceError. • It applies to let, const, class, and other lexical declarations.

Example

Code
{
  // console.log(value); // ReferenceError
  const value = 5;
  console.log(value);
}
Output
5

Quick Revision

Lexical bindings cannot be accessed before initialization.