process.nextTick(function(){
console.log(7);
});
new Promise(function(resolve){
console.log(3);
resolve();
console.log(4);
}).then(function(){
console.log(5);
});
process.nextTick(function(){
console.log(8);
});
这段代码运行结果是3,4,7,8,5
process.nextTick和Promise都是Microtasks,为什么process.nextTick会先执行?
相关分类