MediumHoisting💻 Output Question

Last function declaration wins

💡

Hint

Multiple function declarations with the same name: the last one wins.

What does this output?

console.log(fn());
function fn() { return 1; }
function fn() { return 2; }

Correct Output

2

Why this output?

Explanation: Both function declarations are hoisted. The second overwrites the first. Only the last one remains.

Key Insight: Multiple function declarations with the same name: the last one wins.

More Hoisting Output Questions

Easyvar declaration hoisted as undefinedEasyFunction declaration fully hoistedEasyFunction expression not hoistedMediumLocal var shadows outer — from start of function

Practice predicting output live →

66 output questions with instant feedback

💻 Try Output Quiz