title: Javascript how to store predefined function (with arguments)
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1451009/javascript-infamous-loop-problem">Javascript infamous Loop problem?</a>  </p>
  </blockquote>
  
  
  
  <p>I have the following:</p>
  
  <pre><code>function test(a,b,c){
      console.log(a+b+c);
  }
  for (var i=0; i &lt; array.length; i++){
      steps.push(
          function(){ test(array[i].something, array[i].wow, i);}
      );
  </code></pre>
  
  <p>I want to store functions with several parameters, and bind them to buttons later when the DOM is loaded</p>
  
  <pre><code>for (var i=0; i&lt;steps.length; i++){
      $('#mydiv li a').eq(i).click(steps[i]);
  }
  </code></pre>
  
  <p>It's not really working since steps[i] contains do(array[i].something, array[i].wow, i); instead of do('bob', 'john', 1) for example</p>
  
  <p>I have tried using the .apply javascript function but it will execute in the loop, instead of storing them</p>