Node.js Timer functions are worldwide capacities. You don't have to utilize require() work so as to utilize clock functions. We should see the rundown of clock functions.
Set clock functions:
- setImmediate(): It is utilized to execute setImmediate.
- setInterval(): It is utilized to characterize a period interval.
- setTimeout(): ()- It is utilized to execute a one-time callback after postponement milliseconds.
Clear clock functions:
- clearImmediate(immediateObject): It is utilized to stop an immediateObject, as made by setImmediate
- clearInterval(intervalObject): It is utilized to stop an intervalObject, as made by setInterval
- clearTimeout(timeoutObject): It forestalls a timeoutObject, as made by setTimeout
Node.js Timer setInterval() Example
This model will set a period interim of 1000 millisecond and the predefined remark will be shown after each 1000 millisecond until you end.
Open Node.js command prompt and run the following code: