August 17, 2024
JavaScript setInterval method
setInterval method is a method of window object which is use to execute a statement or statements or call a function repeatedly after certain time period. Mainly setInterval method required two arguments first is expression which you want to execute and second argument required time in milliseconds. After the time you will pass as an argument your first argument which is also a JavaScript statement will be executed repeatedly.
Syntax
setInterval(expression, millisecond);
Example
setInterval('alert("Hello world")', 5000);
In above mentioned example ‘Hello world’ alert message will appear on the screen after every five seconds again and again.