下面这段代码需在node环境中执行
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');
})
以下是我在node环境下执行打印的内容:
glob1
glob1_promise
glob2_promise
glob1_nextTick
glob2_nextTick
glob1_then
glob2_then
想问问.then()中的jobs为啥打印的比.nextTick()中的jobs晚?它们之间的执行顺序是怎样?
https://segmentfault.com/q/10...