The setImmediate() function is meant to execute a single script once the current event loop is complete.
The setTimeout() function is used to hold a script and schedule it to be run after a certain time threshold is over.
The order of execution will solely depend on the context in which the functions are called. If called from the main module, the timing will be based on the performance of the process.