Possible Duplicate:
Javascript closure inside loops - simple practical example
for (i = 0; i < 100; i++) {
setTimeout(function() {
console.log(i);
}, 500)
}
In the above code, it will print only 100. I know the reason. But how do i send the current i value to the callback in setTimeout
?