DEV Community

Cover image for Use of setInterval method in Javascript
 Rahul Gupta
Rahul Gupta

Posted on

Use of setInterval method in Javascript

The setInterval() method is used to call a function or evaluate an expression at specified intervals (in milliseconds). For example, let’s log a message after 2 seconds using the setInterval method,

An example of code below will log a message after 2 seconds using the setTimeInterval method:

setInterval(function () {
console.log("The Coding dev");
}, 2000);

Top comments (0)