Javascript Timers #React Qucik Notes.

Ajay Baraiya - Sep 4 '22 - - Dev Community

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();
Enter fullscreen mode Exit fullscreen mode

2. setInterval();

const myFunc = () => {return setInterval(() => {console.log("executing every 2 sec")},2000);};

myFunc();

//ClearInterval(myFunc); //Call this function to clear running interval
Enter fullscreen mode Exit fullscreen mode
. . . . . . . . . . . . . . . . . . .