In JavaScript, How can I call a function after a specific time interval?
Here is my function I want to run:
function FetchData() {
}
In JavaScript, How can I call a function after a specific time interval?
Here is my function I want to run:
function FetchData() {
}
ECMAScript 6 introduced arrow functions so now the setTimeout() or setInterval() don't have to look like this:
setTimeout(function() { FetchData(); }, 1000)
Instead, you can use annonymous arrow function which looks cleaner, and less confusing:
setTimeout(() => {FetchData();}, 1000)
setTimeout(() => {
console.log('Hello Timeout!')
}, 3000);
setInterval(() => {
console.log('Hello Interval!')
}, 2000);