Function in Scope Before Declaration
<p>I read in a book about function declaration. The code goes like this.</p>

<pre><code>function outer(){
    assert(typeof inner === "function", "inner() in scope before declaration");
    function inner(){}
    assert(typeof inner === "function", "inner() in scope after declaration");
    assert(typeof window.inner === "undefined", "inner() undefined in global space")
}
</code></pre>

<p>When the tests are run all the three statements are asserted true, showing that the inner() function existed in scope before its declaration. My concept about javascript is that the script is executed line by line and the functions should be declared before there call. </p>

<p>The question is how can the inner function exist in the scope before its declaration?</p>
