1.

Differentiate between process.nextTick() and setImmediate()?

Answer»

Both can be used to switch to an asynchronous mode of OPERATION by listener FUNCTIONS

process.nextTick() sets the callback to execute but setImmediate pushes the callback in the queue to be executed. So the event loop runs in the following manner

timers–>pending callbacks–>idle,prepare–>connections(poll,data,ETC)–>CHECK–>close callbacks

In this process.nextTick() method adds the callback function to the START of the next event queue and setImmediate() method to place the function in the check phase of the next event queue.



Discussion

No Comment Found