This is an example:
function func1() { setTimeout(function(){doSomething();}, 3000); } for(i=0;i<10;i++) { func1(); }
after executing
The loop will schedule 10 timeouts all to be completed after 3 seconds. You can use recursion with setTimeout:
setTimeout
function loopAsync(delay, n, f) { setTimeout(function() { if (n > 0) { f() loopAsync(delay, n - 1, f) } }, delay) } loopAsync(3000, 10, doSomething)