The ECMAScript specification goes into detail about what happens when control enters the execution context of a function within a function.
function foo() {
function bar() {
}
bar(); // Control will be given to the bar function. Details specified by spec
}
There also is an explanation of what happens when control enters global code.
<script>
// Entering global code! Details specified by spec
</script>
However, there is nothing specifying what happens when entering control for a function defined in the global code.
<script>
function foo() {
}
foo(); // Calling a function defined in the global environment...not specified by spec
</script>
Edit: The reason this is important to me is because I'm curious what the internal [[Scope]] property of the function called by the global code will be. I assume it will be the lexical environment of the global execution context, but there's nothing that specifies this in the specification.
I think you misinterpreted that sentence (from §10.4.3, Entering Function Code):
The following steps are performed when control enters the execution context for function code contained in function object
F
, a caller providedthisArg
, and a caller providedargumentsList
[…]
It does not mean that the function which is entered must be contained in F
, but that the code that is entered is contained in the function F
(which you are invoking).
The [[Call]]
method which is used when calling a function does not distinguish between global/local declared or invoked functions.