EasyHoisting💻 Output Question

Function expression not hoisted

💡

Hint

Function expressions (var fn = function(){}) — only the var declaration is hoisted, as undefined.

What does this output?

console.log(typeof greet);
var greet = function() { return 'hello'; };
console.log(typeof greet);

Correct Output

undefined
function

Why this output?

Explanation: var greet is hoisted as undefined. The assignment happens at runtime. Before it, greet is undefined.

Key Insight: Function expressions (var fn = function(){}) — only the var declaration is hoisted, as undefined.

More Hoisting Output Questions

Easyvar declaration hoisted as undefined→EasyFunction declaration fully hoisted→MediumLocal var shadows outer — from start of function→MediumFunction declaration takes priority over var in hoisting→

Practice predicting output live →

66 output questions with instant feedback

💻 Try Output Quiz