DEV Community

Discussion on: What's the output?

Collapse
 
akh16 profile image
akh16 • Edited

can you explain, why out is function

Collapse
 
ml318097 profile image
Mehul Lakhanpal

Ok, so due to hoisting, the variables are put first followed by functions.
So it looks like:

function func(){
    var foo;
    function foo(){};
    return foo;

    foo = 1;
    foo = 'hello';
}