Skip to content

Instantly share code, notes, and snippets.

@RodolfoSilva
Last active February 4, 2018 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RodolfoSilva/9049257 to your computer and use it in GitHub Desktop.
Save RodolfoSilva/9049257 to your computer and use it in GitHub Desktop.
diferenca-entre-settimeout-e-setinterval-2
const $watch = document.querySelector("#relogio")
const $timeout = document.querySelector("#delay")
const showCurrentTime = () => {
const date = new Date()
$watch.innerHTML = `${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`
}
setTimeout(() => {
$timeout.innerHTML = `setTimeout foi executado com sucesso.`;
}, 5000);
setInterval(showCurrentTime, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment