Nodejs Event Loop
@Sunny Setia
function performNextTick() {
process.nextTick(() => {
console.log("Inside nextTick | outside setTimeout");
setTimeout(() => {
console.log("Inside nextTick | Inside setTimeout");
process.exit();
}, 0);
});
}
setInterval(() => {
console.log("setInterval");
}, 0);
performNextTick();
Option 1
Inside nextTick | outside setTimeout Inside nextTick | Inside setTimeout setInterval
Option 2
Inside nextTick | outside setTimeout setInterval Inside nextTick | Inside setTimeout
Option 3
setInterval Inside nextTick | outside setTimeout Inside nextTick | Inside setTimeout
Option 4
Inside nextTick | Inside setTimeout Inside nextTick | outside setTimeout setInterval