DEV Community

loading...

Discussion on: What's the output?

Collapse
akh16 profile image
akh16

can you explain, why out is function

Collapse
318097 profile image
Mehul Lakhanpal Author

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';
}