162
rated 0 times
[
164]
[
2]
/ answers: 1 / hits: 21365
/ 12 Years ago, thu, november 1, 2012, 12:00:00
Possible Duplicate:
setTimeout in a for-loop and pass i as value
for (var i = 0; i < 5; i++) {
setTimeout(function (i) {
console.log(this.i)
}, 1000);
}
This prints 5
five times. How can I write the loop so that it prints 0, 1, 2, 3, 4
?
More From » javascript