computer-scienceangular-roadmapbackend-roadmapblockchain-roadmapdba-roadmapdeveloper-roadmapdevops-roadmapfrontend-roadmapgo-roadmaphactoberfestjava-roadmapjavascript-roadmapnodejs-roadmappython-roadmapqa-roadmapreact-roadmaproadmapstudy-planvue-roadmapweb3-roadmap
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
648 B
648 B
You can run some codes on interval using setInterval
function in JavaScript. It accepts a function and a time interval in milliseconds. It returns a unique id which you can use to clear the interval using clearInterval
function.
const intervalId = setInterval(() => {
console.log('Hello World');
}, 1000);
// Output:
// Hello World
// Hello World
In the above code, the setInterval
function runs the callback function every 1000 milliseconds (1 second) and prints Hello World
to the console. It returns a unique id which you can use to clear the interval using clearInterval
function.
clearInterval(intervalId);