首页 > 其他 > 详细

promise和settimeout执行顺序

时间:2019-09-16 20:51:39      阅读:76      评论:0      收藏:0      [点我收藏+]

```
console.log(1);
new Promise(function (res,rej) {
console.log(2);
res();
}).then(function () {
console.log(3);
Promise.resolve().then(function () {
console.log(5);
setTimeout(function () {
console.log(6);
Promise.resolve().then(function () {
console.log(7);
});
setTimeout(function () {
console.log(8)
},0);
},0)
})
}).then(function () {
console.log(4);
});
setTimeout(function () {
console.log(9);
new Promise(function (res) {
res();
console.log(10);
}).then(function () {
console.log(11);
})
});
Promise.resolve().then(function () {
setTimeout(function () {
Promise.resolve().then(function () {
console.log(12);
});
console.log(13);
},0)
});
setTimeout(function () {
setTimeout(function () {
setTimeout(function () {
Promise.resolve().then(function () {
console.log(14);
});
console.log(15);
});
console.log(16);
});
console.log(17);
});
console.log(18);
new Promise(function (res) {
console.log(19);
setTimeout(function () {
console.log(20);
},0)
})
```

promise和settimeout执行顺序

原文:https://www.cnblogs.com/Idacn/p/11529394.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!