title: Alternative to making functions in a loop
body: <p>I have a the following code</p>
  
  <pre><code>this.addHandlers = function (interactions) {
      for(var eventType in interactions) {
          if(interactions[eventType]) {
              this.on(eventType, function () {
                  // do something with interactions[eventType]
              });
          } 
      }
  };
  </code></pre>
  
  <p>jshint gives me the following warning</p>
  
  <pre><code>Don't make functions within a loop
  </code></pre>
  
  <p>But as I need the eventType variable which is created in the loop to complete the closure within my event handler I can't create the function outside my loop. I could get rid of the warning by moving the call to <code>this.on</code> into a function, but I feel like this is missing the point.</p>
  
  <p>How could I not make the function in the loop?</p>