the code is scanned for function terms, and each func. declaration is "performed" (by developing a function object) along with a named mention of the that function is produced (to ensure that this function could be known as from inside an argument)
the claims are performed (examined) sequentially (because they come in the code)
Due to that, this works all right:
<script> foo() function foo() </script>
Even though "foo" function is known as prior to it being declared, it really works since the function declaration is examined prior to the statement.
However, this doesn't work:
<script> foo() </script> <script> function foo() </script>
On the other hand, this works:
<script> function foo() </script> <script> foo() </script>
Now, note this...
<script> // presuming that foo isn't defined foo() alert(1) </script>
However, within this situation...
<script> // presuming that foo isn't defined foo() </script> <script> alert(1) </script>
Now, my conclusions are:
Please fact-take a look publish and let me know basically got a problem.
Also, I haven't found assets that explain the actions pointed out within this publish, and that i think that the browser makers should have released such assets somewhere, if you learn about them, please supply the links for them.
His undertake this problem is: Each SCRIPT block consists of global code. Performing each SCRIPT block produces a brand new execution context. Therefore, each SCRIPT block features its own execution context, but all individuals execution contexts share exactly the same Global object.
SCRIPT blocks might be seen as different "sub-programs" with similar shared condition.
In addition, the ECMAScript spec (3rd edition) states (chapter 10): "Global code is source text that's treated being an ECMAScript Program."