Skip to content

Instantly share code, notes, and snippets.

@azamsharp
Created April 23, 2020 16:41
Show Gist options
  • Save azamsharp/45421e33728c4b1e631aae594788f128 to your computer and use it in GitHub Desktop.
Save azamsharp/45421e33728c4b1e631aae594788f128 to your computer and use it in GitHub Desktop.
let wordList = document.getElementById("wordList")
function tick() {
console.log("TICK")
}
// 1000 millisecond is 1 second
// tick is used here as a callback function
// means that it will be called back in 5 seconds
// setTimeout is called only once
//window.setTimeout(tick,5000)
// setInterval is called repeatedly
//window.setInterval(tick,2000)
// setInterval using anonymous function
let id = window.setInterval(function() {
console.log("TICK")
let tickItem = `<li>TICK</li>`
wordList.insertAdjacentHTML('beforeend',tickItem)
},1000)
window.setTimeout(function() {
// clear or stop the interval
window.clearInterval(id)
},5000)
function getCustomers() {
window.setTimeout(function() {
console.log("TIMEOUT FUNCTION FIRED")
},1000)
console.log("GET CUSTOMERS FIRED")
}
getCustomers()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment