JavaScript中的事件循环与消息队列
宏任务和微任务有什么区别
new Promise(function (resolve) {
console.log('1');
new Promise(function (resolve) {
console.log('3');
new Promise(function (resolve) {
console.log('5');
resolve();
}).then(function () {
console.log('6');
});
resolve();
}).then(function () {
console.log('4');
});
resolve();
}).then(function () {
console.log('2');
});
参考上面两个文章,上面代码输出为:1 3 5 6 4 2
网友评论