DEV Community

loading...

Discussion on: What's the output?

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