In this gist i will explain about the working of Phases in Event Loop, please refer below js file and run each example by uncommenting the code snippet one by one.
setImmediate(() => {
console.log('set immediate 2')
})
setTimeout(() => {
console.log('timeout 3')
})
process.nextTick(() => {