DEV Community

Ajay Baraiya
Ajay Baraiya

Posted on • Edited on

Javascript Timers #React Qucik Notes.

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

Top comments (0)