I thought that
function foo() { return 42; }
is mostly equivalent to
var foo = function() { return 42; }
except that foo.name differs in both cases. But regarding the scope, I thought it would be the same.
However, then I stumbled upon this code:
function demo() {
    return foo;
    function foo() { return 42; }
}
And demo() actually returns the foo function, i.e. demo()() == 42.
So, it seems that function evaluation is probably already done earlier, probably at compile stage.
Is my guess correct? Is that standard? (I'm using V8.)
(I just found this - it might be a duplicate.)
 
     
     
     
    