How to stop javascript for executing for some specific time period?
Using setTimeout
function am able to execute a block of statements after a delay but during the wait time the statements next to the setTimeout
are being executed. Can I suspend this synchronous execution.
As per requirement I have setTimeout
function in a for loop. But during the wait time the loop is being executed.
Here is the sample code:
for(i = 0;i < n;i++){
setTimeout(function(){
// Accessing the loop variable i inside this function
},3000);
}