-
-
Save azamsharp/45421e33728c4b1e631aae594788f128 to your computer and use it in GitHub Desktop.
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
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