Remeber below functions from which we can do all timer related things.
1. SetTimeout();
const myFunc = () => {return setTimeout(() => {console.log("executed after 2 sec")},2000);}; myFunc();
2. setInterval();
const myFunc = () => {return setInterval(() => {console.log("executing every 2 sec")},2000);}; myFunc(); //ClearInterval(myFunc); //Call this function to clear running interval
Top comments (0)