title: How does implicit passing of object reference work?
body: <p>I have some Javascript code which works fine so far but I do not understand the how the variable "me" is set in the function "run"? </p>
  
  <pre><code>GameLoop.prototype.run = function() {
  
  this.startTime = new Date().getTime();
  var currentTimeMillis = this.startTime;
  var loops;
  var interpolation=0.0;
  this.running=true;
  
  return function(me){
      loops = 0;
      while (new Date().getTime() &gt; currentTimeMillis &amp;&amp; loops &lt; me.MAX_FRAMESKIP) {
          me.updateGame();
          currentTimeMillis += me.SKIP_TICKS;
          loops++;
      }
      interpolation = parseFloat(new Date().getTime() + me.SKIP_TICKS - currentTimeMillis) / parseFloat(me.SKIP_TICKS);
      me.drawGame(interpolation);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>The function is called continuously by the browser's animate function below. Since I do not pass any reference to the call f.run(), i guess the correct reference to me is set implicitly. Can someone explain me or give me some useful links which explains this behaviour?</p>
  
  <pre><code>GameLoop.prototype.recursiveAnim = function() {
          var f = this.run();
          f.run();
          this.animFrame( this.recursiveAnim );
      };
  </code></pre>