Javascript parse/evaluation order?
<p>This is probably a nub question, but I don't understand why this works:</p>

<pre><code>&lt;script type="text/javascript"&gt;
    alert(foo);
    function foo() { }
&lt;/script&gt;
</code></pre>

<p>This alerts "function foo() { }", but I expected the alert to be evaluated before the function foo was defined. Can someone explain what I don't understand about parse/evaluation order or point me to a resource that does?</p>
