[Edit]
+
0
-
0

js for loop with setTimeout() example

1 2 3 4 5 6 7 8 9 10 11 12
// print values from 0 to 9 in the console every second: for (var i = 0; i < 10; i++) { (function(index) { setTimeout(function() { console.log(index); }, i * 1000); })(i); } // Warning: this solution schedules at once all iterations (it may be not effective for the big amount of the iterations).