How can you use a function that is defined below its usage?
<p>I always thought that <code>function a(){}</code> is identical to <code>a = function(){};</code></p>

<p>However, these two snippets behave differently:</p>

<pre><code>a();
function a() {
  alert("Booya");
}
</code></pre>

<p>Prints Booya.</p>

<pre><code>a();
a = function() {
  alert("Booya");
}
</code></pre>

<p>Fails with an exception, which makes sense, since a is really not defined when called.</p>

<p>So - what kind of 'magic' lets the first snippet work, even though <code>a()</code> is defined below its point of usage?</p>
