home PYTHONJAVA
 

Node.js Timer


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.

File: timer1.js

  1. setInterval(function() {  
  2.  console.log("setInterval: Hey! 1 millisecond completed!..");   
  3. }, 1000);  

Open Node.js command prompt and run the following code:

  1. node timer1.js  





welookups is optimized for learning.© welookups. 2018 - 2019 All Right Reserved and you agree to have read and accepted our term and condition.