title: Javascript nested function losing scope
body: <p>Can someone explains the scope binding of the following code please</p>
  
  <pre><code>window.name = "window";
  
  object = {
         name: "object",
         method: function() {
               nestedMethod: function() {
                     console.log(this.name);
               }
               nestedMethod();
         }
  }
  
  object.method();  // print 'window'
  </code></pre>
  
  <p>I think my question is more about <code>this</code>...why is <code>this</code> losing the scope and default to the global scope ? do all the anonymous functions that we created will go on the global scope ?</p>