Created
March 5, 2017 21:36
-
-
Save ivcn/e6e6f7ec028d9bf9b86347c23bce2a4b to your computer and use it in GitHub Desktop.
Loop with timeout in JavaScript
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
| var i = 0; | |
| function loop () { | |
| setTimeout(function () { | |
| doSomething(); | |
| i++; | |
| if (i < 20) { | |
| loop(); | |
| } | |
| }, 300) | |
| } | |
| loop(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment