Repeatedly executes a function at specified intervals.
A TimerId that can be used to cancel the interval
const intervalId = timers.setInterval(() => {
console.log('Printing this every 1 second')
}, 1000)
The function to execute at each interval
The interval in milliseconds
Delays the execution of a function by a given amount of milliseconds.
A TimerId that can be used to cancel the timeout
const timeoutId = timers.setTimeout(() => {
console.log('1 second passed')
}, 1000)
The function to execute after the delay
The delay in milliseconds
Cancels an interval previously established by setInterval.
Example