The setImmediate function delays the execution of a function to be called after the current event loops finish all their execution. It’s very similar to calling setTimeout with 0 ms delay.
setImmediate
setTimeout
Visit the following resources to learn more: