Created
February 21, 2014 06:36
-
-
Save khamiltonuk/9129813 to your computer and use it in GitHub Desktop.
Time based repetition
This file contains hidden or 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
| //Alternative to setInterval | |
| //Set interval will run the function doStuff() every 100ms regardless if doStuff has finished. | |
| setInterval(function(){ | |
| doStuff(); | |
| },100); | |
| //Alternatively you can use argements.callee after doStuff(); which will is wrapped in a self invoking anyonomous self invoking function | |
| (function(){ | |
| doStuff(); | |
| setTimeout(arguments.callee,100); | |
| })(); | |
| // arguments.callee calls the parent function, support is wide spreed with no plans of removing but in older browsers for arguments.callee is unreliable | |
| // arguments.callee has been removed from ES5 strict mode | |
| //You can get around this by declaring the function with a name and calling it within the setTimeout | |
| (function doStuff() { | |
| // Statements | |
| setTimeout(doStuff, 100); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment