Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

NodeJS process.nextTick() Method

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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.nextTick()

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
Last Updated : 30 Aug, 2022
Like Article
Save Article
Similar Reads
Related Tutorials