title: Accessing this in anonymous function
body: <p>I want to create a <code>prototype</code> function that has its own scope. For this, I use an anonymous function but I cannot find a way to access the members of the object.</p>
  
  <p>Here is a simplified version of what I am trying to achieve:</p>
  
  <pre><code>function F() {
      this.counter = 0;
  } 
  
  F.prototype.increment = (function() {
      var lastIncrementTime = -1;
      var caller = this; // &lt;--- it fails here because this is the Window object
      return function(time) {
          if (time &gt; lastIncrementTime) {
              caller.counter++;
              lastIncrementTime = time;
              return caller.counter;
          }
          return caller.counter;
      }
  })();
  
  f = new F();
  
  f.increment();
  </code></pre>
  
  <p>I know it fails because this does not refer to <code>F</code> or the <code>f</code> object.</p>
  
  <p>Is there a way to access it?</p>