What is the difference between setImmediate() and setTimeout()?

setImmediate() executes a script once the current poll or the event loop phase has completed.

setTimeout() is used to schedule scripts to be run after a minimum threshold has elapsed.

The order in which these timers are executed varies on the context in which they are used. If both are called from within the module, timing will be bound by the process performance.

Suggest An Answer

No suggestions avaliable!

Latest post from Node js Interview Questions

Ask Question