获得徽章 0
求解答node event loop
new Promise(function (resolve) {
console.log("1");
resolve();
}).then(function () {
console.log("2");
process.nextTick(() => {
console.log("x");
});
new Promise(function (resolve) {
console.log("3");
resolve();
}).then(function () {
console.log("4");
});
setTimeout(function () {
console.log("5");
});
});
结果:node 15.6
1 2 3 4 x 5
没想明白 process.nextTick 怎么在 4 后面
new Promise(function (resolve) {
console.log("1");
resolve();
}).then(function () {
console.log("2");
process.nextTick(() => {
console.log("x");
});
new Promise(function (resolve) {
console.log("3");
resolve();
}).then(function () {
console.log("4");
});
setTimeout(function () {
console.log("5");
});
});
结果:node 15.6
1 2 3 4 x 5
没想明白 process.nextTick 怎么在 4 后面
展开
1
点赞
赞了这篇文章
赞了这篇文章