🔴 HardHoisting💻 Output Question

Hoisting inside blocks

💡

Hint

Block-level function declarations behave inconsistently — avoid them. Use function expressions inside blocks.

What does this output?

console.log(typeof foo);

{
  function foo() {}
}

console.log(typeof foo);

Correct Output

undefined
function

Why this output?

Explanation: In non-strict mode, block-level function declarations are partially hoisted to the enclosing function scope but only initialized when the block is reached. Behavior varies across environments.

Key Insight: Block-level function declarations behave inconsistently — avoid them. Use function expressions inside blocks.

More Hoisting Output Questions

🟢 Easyvar hoisting→🟢 EasyFunction declaration hoisting→🟡 MediumFunction expression not hoisted→🟡 Mediumlet temporal dead zone→

Practice predicting output live →

66 output questions with instant feedback

💻 Try Output Quiz