However, it seem that the ordering is a bit different, from my test, it is more like: process.nextTick, setTimeout/setInterval, setImmediate.
Here is the sample test code and result (Node.JS v4.1.0):
setImmediate(function() {
console.log("from setImmediate");
});
setTimeout(function() {
console.log("from setTimeout");
}, 10);
process.nextTick(function() {
console.log("from process.nextTick");
});
console.log("hello");
output:
hellofrom process.nextTickfrom setTimeoutfrom setImmediate
Useful for someone having difficult in the relevant subject. Thanks for this blog. I can share it with my friend. Have a great day!
ReplyDelete