🟑 MediumHoistingπŸ’» Output Question

let temporal dead zone

πŸ’‘

Hint

let/const are in TDZ from block start to declaration. Even typeof throws ReferenceError in TDZ.

What does this output?

console.log(typeof x);
console.log(typeof y);

let x = 1;
var y = 2;

Correct Output

ReferenceError: Cannot access 'x' before initialization

Why this output?

Explanation: let is hoisted but stays in the Temporal Dead Zone (TDZ) until its declaration. Accessing it before declaration throws ReferenceError, not undefined. typeof does NOT save you here.

Key Insight: let/const are in TDZ from block start to declaration. Even typeof throws ReferenceError in TDZ.

More Hoisting Output Questions

🟒 Easyvar hoistingβ†’πŸŸ’ EasyFunction declaration hoistingβ†’πŸŸ‘ MediumFunction expression not hoistedβ†’πŸ”΄ HardFunction vs var hoisting orderβ†’

Practice predicting output live β†’

66 output questions with instant feedback

πŸ’» Try Output Quiz