title: Passing custom variable in iterator function in underscore.js
body: <p>I need to call a method for each item in the object with custom args.</p>
  
  <pre><code>var data2 = {
      "prop1":[{"foo":"val11"},{"bar":"val12"}],
      "prop2":[{"foo":"val21"},{"bar":"val22"}]
      }
  
  function processData(data2){
    for(key in data2){
      _.each(data2[key],iterator,this);
    }
  }
  
  function iterator(data){
      console.log(data);
      console.log(this.key) // need value of 'key' here.
  }
  
  processData(data2);
  </code></pre>
  
  <p>Another way of doing the same is :</p>
  
  <pre><code>function processData(data2){
    for(key in data2){
      _.each(data2[key],function(data,index,list){
              iterator(data,key);
      });
    }
  }
  
  function iterator(data,key){
      console.log(data);
      console.log(key) // need value of 'key' here.
  }
  </code></pre>
  
  <p><strong>Is there any simpler/cleaner way to achieve the same results? Or any other function that does the same thing?</strong></p>