title: Why does this return a reference to the global window object, even though 'this' is within another function
body: <pre><code>if (typeof obj == 'undefined') {
    obj = {};
  }
  
  obj.thing = new function () {
    if (typeof this.global == 'undefined') {
      this.global = (function () {return this;})();
    }
  }
  </code></pre>
  
  <p>this.global is assigned to this inside of a function. So, why does this return a reference to the window object? </p>
  
  <pre><code>console.log(this) &gt; DOMWindow
  console.log(obj.thing.global) &gt; DOMWindow
  console.log(window) &gt; DOMWindow
  </code></pre>
  
  <p>I would love to understand this better.</p>