ForgeFrontend — Prepare, Practice, Crack
Secure checkout
Lifetime access
Instant Drive delivery
Free updates forever

Prepare · Practice · Crack

What is hoisting? What is the Temporal Dead Zone?

Quick answer

Declarations are processed before code runs. `var`/functions are usable early; `let`/`const` exist but are uninitialised (the TDZ) until their line.

In detail

During the creation phase the engine registers declarations before executing any line. `var` is initialised to `undefined` and function declarations are hoisted whole (callable before they appear). `let` and `const` are hoisted too, but stay in the Temporal Dead Zone — the gap between entering the scope and the declaration line — where accessing them throws.

greet();              // "hi"  — function declaration hoisted
function greet() { return "hi"; }

run();                // TypeError — var holds undefined here
var run = () => {};

Why interviewers ask this: Hoisting underlies many output-prediction questions.

Common follow-up questions

  • Are function expressions hoisted?
  • Why does let throw but var doesn't?

This is 1 of 118+ questions in the JavaScript Interview Kit

Get every question with detailed answers, follow-ups and real code — plus coding challenges and a last-minute revision sheet. One-time payment, instant access.

⚡ Get the JavaScript Interview Kit → ₹299

Full kit

JavaScript Interview Kit · ₹299

Get it →