How to calls a function repeatedly after a specific number of milliseconds in Node.js

1 Answer

0 votes
function func(str) {
    console.log(str);
}

console.log("Before setInterval call");

let timerID = setInterval(func, 1000, "Node.js");

console.log("After setInterval call");



 
 
 
/*
run:
 
Before setInterval call
After setInterval call
Node.js
Node.js
Node.js
Node.js
Node.js
Node.js
Node.js
Node.js
Node.js
Node.js
Node.js
Node.js
Node.js
Node.js
 
*/

 



answered Aug 11, 2022 by avibootz
...