Skip to content

Instantly share code, notes, and snippets.

@NigelEarle
Created April 9, 2017 05:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NigelEarle/4ed80db34818b2b90015f67e68ebab7d to your computer and use it in GitHub Desktop.
Save NigelEarle/4ed80db34818b2b90015f67e68ebab7d to your computer and use it in GitHub Desktop.
setTimeout() in for loop
for (var i = 0;i < 10;i++) {
(function(i) {
setTimeout(function(){
console.log(i);
}, 1000 * i);
})(i);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment