Skip to content

Instantly share code, notes, and snippets.

@aaronmccall
Created October 14, 2011 04:05
Show Gist options
  • Save aaronmccall/1286209 to your computer and use it in GitHub Desktop.
Save aaronmccall/1286209 to your computer and use it in GitHub Desktop.
// How to create a setTimeout-based incrementer that is self-calling
(function() {
var i = 0;
function incrementer(undefined) {
if (i !== undefined && i < 10) {
i++;
console.log('i is %s', i);
setTimeout(incrementer, 500);
}
}
setTimeout(incrementer, 500);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment