Skip to content

Instantly share code, notes, and snippets.

@tmlangley
Created April 8, 2015 16:54
Show Gist options
  • Save tmlangley/46f3997a0ab778ec1d7f to your computer and use it in GitHub Desktop.
Save tmlangley/46f3997a0ab778ec1d7f to your computer and use it in GitHub Desktop.
loop delay with recursion
/**
* From Daniel Vassallo:
* http://stackoverflow.com/questions/3583724/how-do-i-add-a-delay-in-a-javascript-loop/3583740#3583740
*/
(function loop(i) {
setInterval(function() {
// do stuff...
if (--i) loop(i);
}, 2000);
})(10);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment