🟒 EasyHoistingπŸ’» Output Question

var hoisting

πŸ’‘

Hint

var hoisting: declaration hoisted, initialization stays. Result: undefined, not ReferenceError.

What does this output?

console.log(x);
var x = 5;
console.log(x);

Correct Output

undefined
5

Why this output?

Explanation: var declarations are hoisted (moved to top of scope) but NOT initializations. So x exists but is undefined until the assignment runs.

Key Insight: var hoisting: declaration hoisted, initialization stays. Result: undefined, not ReferenceError.

More Hoisting Output Questions

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

Practice predicting output live β†’

66 output questions with instant feedback

πŸ’» Try Output Quiz