title: window.setInterval using local function
body: <p>I'm using <code>window.setInterval</code>, and it must have to be able to access a method that is defined in a "class", but since <code>setInterval</code> is in a scope separate from the method it was defined in, <code>this</code> resolves to <code>window</code> instead of the desired instance of <code>Game</code>. What code can I use to get the desired behaviour of calling <code>Game.update</code> instead of <code>window.update</code>?</p>
  
  <p>(That looks kind of confusing. Maybe the following incorrect code can clear things up a bit.)</p>
  
  <pre><code>game = function () {
      /* ... */
      this.update = function () {
          /* ... */
      }
      this.interval = window.setInterval(this.update /* !!! */, 50);
  }
  </code></pre>