Why is it illegal to have var inside an if() expression in javascript?
<p>At least in V8 something like</p>

<pre><code>if((var i = x*x) == 2){}
</code></pre>

<p>will give an error about an unexpected 'var' keyword. However there is no error if the var happens before the if() but I still leave the assignment of i in the expression. Why such an odd exception? Is this in the ECMA script standard somewhere? Is there a undetectable closure happening within the evaluation of the if() expression so leaving in the var would make my assignment disappear?</p>

<p>To further generalize it appears that <code>var</code> must have no non-white space characters preceding it.</p>
