Possible Duplicate:
Javascript infamous Loop problem?
I have the following:
function test(a,b,c){
console.log(a+b+c);
}
for (var i=0; i < array.length; i++){
steps.push(
function(){ test(array[i].something, array[i].wow, i);}
);
I want to store functions with several parameters, and bind them to buttons later when the DOM is loaded
for (var i=0; i<steps.length; i++){
$('#mydiv li a').eq(i).click(steps[i]);
}
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
I have tried using the .apply javascript function but it will execute in the loop, instead of storing them