-
-
Save por/1372858 to your computer and use it in GitHub Desktop.
setInterval run once, then keep running
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
setInterval((function fn () { | |
console.log(new Date()); // run some arbitrary code | |
return fn; // here be the magic | |
}()), 1000); | |
// ^---- and that runs the function, and the return val is assign to the interval |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment