Created
July 24, 2020 16:46
-
-
Save Rony20191/5b883b7cad8073acd19c7f80643445ec to your computer and use it in GitHub Desktop.
Created TimerJavascript
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
| setTimeout( function() { | |
| console.log( 'Executa uma vez após 1 segundo.' ); | |
| }, 1000 ); | |
| setInterval( function() { | |
| console.log( 'Executa infinitamente, 1 vez por segundo.' ); | |
| }, 1000 ); | |
| /* | |
| setInterval() executa infinitamente, até que você execute clearInterval(); | |
| setTimeout() executa apenas uma vez. | |
| */ | |
| var counter = 0; | |
| var timer = setInterval(function() { | |
| if( counter >= 10 ) { | |
| clearInterval( timer ); | |
| } | |
| console.log( counter++ ); | |
| }, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment