why self invoking function throws error without enclosing parenthesis : <p>I have two code snippet. First one is working fine but the second one is giving error.</p>

<pre><code>var b = function abc() {
    alert(a);
}()
</code></pre>

<p>Here I am getting the alert message.</p>

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

<p>Here I am getting error."Uncaught SyntaxError: Unexpected token )"
I am using chrome browser.</p>

<p>Again the following is working. </p>

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

<p>What is the purpose of the enclosing parentheses?</p>
