Node.js Timers Complete Reference Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report Node.js Timers module in Node.js contains various functions that allow us to execute a block of code or a function after a set period of time. The Timers module is global, we do not need to use require() to import it. Example: JavaScript // Node.js program to demonstrate the // Immediate Class methods // Setting Immediate by setImmediate Method const Immediate = setImmediate(function alfa() { console.log("0.>", 12); }); // Printing Immediate.hasRef method console.log("1.>", Immediate.hasRef()); // Returns true // Printing Immediate.ref before unref console.log("2.>", Immediate.ref()); // Returns timer reference // Printing Immediate.unref method console.log("3.>", Immediate.unref()); // Returns Immediate reference and // sets hasRef to false // Printing Immediate.hasRef before unref console.log("4.>", Immediate.hasRef()); // Returns false // Clears setInterval Immediate clearImmediate(Immediate); // Prints after clearing Immediate console.log("5.>", 2); Output: 1.> true 2.> Immediate { _idleNext: null, ……, [Symbol(triggerId)]: 1 } 3.> Immediate { _idleNext: null, ……, [Symbol(triggerId)]: 1 } 4.> false 5.> 2 The Complete List of Timers is listed below: Node.js Timers Class Description Immediate Timer ClassImmediate Class has an object (setImmediate()) which is created internally to scheduled actions, and (clearImmediate()) can be passed in order to cancel those scheduled actions.Timeout Timer ClassTimeout Class has an object (setTimeout()/setInterval()) which is created internally for scheduled actions, and (clearTimeout()/clearInterval()) can be passed in order to cancel those scheduled actions. Create Quiz Comment K kartik Follow 0 Improve K kartik Follow 0 Improve Article Tags : Web Technologies Node.js Node.js-Timers Explore Introduction & Installation NodeJS Introduction3 min readNode.js Roadmap: A Complete Guide6 min readHow to Install Node.js on Linux6 min readHow to Install Node.js on Windows5 min readHow to Install NodeJS on MacOS6 min readNode.js vs Browser - Top Differences That Every Developer Should Know6 min readNodeJS REPL (READ, EVAL, PRINT, LOOP)4 min readExplain V8 engine in Node.js7 min readNode.js Web Application Architecture3 min readNodeJS Event Loop5 min readNode.js Modules , Buffer & StreamsNodeJS Modules5 min readWhat are Buffers in Node.js ?4 min readNode.js Streams4 min readNode.js Asynchronous ProgrammingAsync Await in Node.js3 min readPromises in NodeJS7 min readHow to Handle Errors in Node.js ?4 min readException Handling in Node.js3 min readNode.js NPMNodeJS NPM6 min readSteps to Create and Publish NPM packages7 min readIntroduction to NPM scripts2 min readNode.js package.json4 min readWhat is package-lock.json ?3 min readNode.js Deployments & CommunicationNode Debugging2 min readHow to Perform Testing in Node.js ?2 min readUnit Testing of Node.js Application5 min readNODE_ENV Variables and How to Use Them ?2 min readDifference Between Development and Production in Node.js3 min readBest Security Practices in Node.js4 min readDeploying Node.js Applications5 min readHow to Build a Microservices Architecture with NodeJS3 min readNode.js with WebAssembly3 min readResources & ToolsNode.js Web Server6 min readNode Exercises, Practice Questions and Solutions4 min readNode.js Projects9 min readNodeJS Interview Questions and Answers15+ min read Like