DEV Community

Sathish K
Sathish K

Posted on

setInterval and addEventListener

** What is the addEventListener() ?**
The addEventListener() method in javascript is used to attach an event handler to a specified element in the DOM.
This method allow you define the function.
That will be executed when a particular event occurs on that element.

element.addEventListener(event, function, options);

Enter fullscreen mode Exit fullscreen mode

What is the setInterval() ?
In JavaScript, setInterval() is a built-in method used to repeatedly execute a specified function or code block at fixed time intervals. It continues to run until explicitly stopped using clearInterval() or until the window/tab is closed.

var intervalID = setInterval(function, delay, [param1, param2, ...]);
Enter fullscreen mode Exit fullscreen mode

Top comments (0)