Javascript variable scope undefined
<p>I want to define a variable to default value if not already defined but found a strange issue.</p>

<p><code>var x =  x || {}</code> works whereas <code>x  = x || {}</code> gives an error.</p>

<p>Output from firebug.</p>

<pre><code>&gt;&gt;&gt; a = a || {};
ReferenceError: a is not defined
[Break On This Error]   
a = a || {};
with(_... {}; }; (line 2)
&gt;&gt;&gt; var b = b || {};
undefined

&gt;&gt;&gt; b;
Object {}
&gt;&gt;&gt; a;
ReferenceError: a is not defined
[Break On This Error]   
</code></pre>

<p>why does the first one give error while the second seems to go through.</p>
