1. Home
  2. Javascript
  3. Delayed iteration loop

Using setTimeout function this loop example lets you delay the iteration.

#javascript#loop
(function iterate(i) {          
    setTimeout(function () {   
       console.log(i);                     
       if (--i) iterate(i);      
    }, 200)
 })(10);
copy
Full Javascript cheatsheet