title: Is 'window' really global in JavaScript?
body: <p>Take this piece of JavaScript code in a browser:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;script&gt;
      console.log(window.someThing);
      var x = 12;
  
      function foo() {
         window.otherThing = x;
      }
  &lt;/script&gt;
  </code></pre>
  <p>Inside <code>foo</code> we can access <code>window</code>. We all know that, but why exactly?</p>
  <ul>
  <li>Is it some kind of special global variable?</li>
  <li>Or does the &quot;root scope&quot; (inside the <code>script</code> tag) have it as an implicit local variable and is it simply &quot;closure-inherited&quot; as any other local variable (like <code>x</code> above) can be?</li>
  </ul>
  <p>And how does that concur with variables declared directly inside the <code>script</code> tag being set as properties of <code>window</code>? (Or is that not so?)</p>
  <pre class="lang-html prettyprint-override"><code>&lt;script&gt;
      var x = 12;
      function() {
         console.log(window.x);
      }
  &lt;/script&gt;
  </code></pre>