This is an example:
function func1() { setTimeout(function(){doSomething();}, 3000); } for(i=0;i<10;i++) { func1(); }
after executing
It is because setTimeout() function is non-blocking. Therefore your setTimeout() function is running only first time.
setTimeout()
Try this code...
var i = 1; function func1(){ setTimeout(function(){ doSomething(); i++; if(i < 10){ func1(); } }, 3000); } func1();