title: Pass variable to closure on event trigger
body: <p>I have a loop where I define a closure for an event:</p>
  
  <pre><code>for (var i = 0; i &lt; 3; i++) {
      obj.onload = function(e) {
          me.myFunction(e, i);
      };
  }
  </code></pre>
  
  <p>I need to pass that counter variable to the function that is called when the <code>load</code> event is triggered. I always get the same value being passed.</p>
  
  <p>How can I pass the right counter value to the function?</p>