Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

NodeJS process.nextTick() Method

  • Last Updated : 08 Mar, 2021

The process object is one of the few global objects provided by the NodeJS core API. It can be accessed from anywhere, thus its methods can also be accessed. Such is a method called process.nextTick() which is used by developers in real-time applications every day to defer the execution of a function until the next Event Loop Iteration.

Syntax:

process.env

Return Value:

In the code of snippet, the second console is printed first because this is a part of the current iteration of the event loop, and the first console is a part of a callback function that is associated with the process.nextTick() executed in the next iteration of the event loop.

Below examples illustrate the use of the process.nextTick() property in NodeJS:



Example:

Javascript




// Node.js program to demonstrate the 
// process.nextTick() Property 
     
// Include process module 
const process = require('process');
  
process.nextTick(() => {
  console.log('Executed in the next iteration');
});
  
console.log('Executed in the current iteration');

Command to run:

node filename

Output:

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!