the following code needs to be executed in the node environment
console.log("glob1");
new Promise(function(resolve) {
console.log("glob1_promise");
resolve();
}).then(function() {
console.log("glob1_then")
})
new Promise(function(resolve) {
console.log("glob2_promise");
resolve();
}).then(function() {
console.log("glob2_then")
})
process.nextTick(function() {
console.log("glob1_nextTick");
})
process.nextTick(function() {
console.log("glob2_nextTick");
})
the following is what I print in node:
glob1
glob1_promise
glob2_promise
glob1_nextTick
glob2_nextTick
glob1_then
glob2_then
I would like to ask why the jobs in .then () prints later than the jobs in .nextTick ()? What is the order of execution between them?