Created
October 14, 2011 04:05
-
-
Save aaronmccall/1286209 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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