The callback passed to the setImmediate function is executed in the next iteration of the event loop over the event queue.
On the other hand, the callback passed to the process.nextTick is executed before the next iteration of the event loop, and after the operation currently running in the program is finished. At the application start, its callback is called before the event loop starts iterating over the event queue.
Therefore, the process.nextTick callback is always called before the setImmediate callback.