for (var i = 0; i < somearray.length; i++) { myclass.foo({\'arg1\':somearray[i][0]}, function() { console.log(somearray[i][0]); }); }
How about a closure:
for (var i = 0; i < somearray.length; i++) { var val = somearray[i][0]; myclass.foo({'arg1': val}, function(v) { return function() {console.log(v) }; }(val) ); }