When creating a global object in JavaScript why do I need to specify the this keyword
<p>Say I'm trying to create a global variable x if it doesn't already exist:</p>

<pre><code>x = x || {};            //This fails. x is not defined
this.x = this.x || {};  //But this works
</code></pre>

<p>I'm running this in Firebug and was surprised that the 1st line failed. I expected x to be attached to the global window object, but it didn't work unless I specified the <code>this</code>.</p>

<p>I'm hoping to improve my understanding of the language. Can someone explain to me why this is?</p>

<p>Thanks for any help.</p>
