I have the following situation:
var foo = [ 0, 1, 2 ] for (var i in foo) { Asyncstuff.get(URI).on(\'response\', function(res) { console.log(i); } }); } <
You need a closure. There are better ways than this, but this should clearly demonstrate the concept:
var foo = [ 0, 1, 2 ] for (var i in foo) { (function(i){ Asyncstuff.get(URI).on('response', function(res) { console.log(i); } }); })(i); }