console.log(1);
new Promise(resolve => {
resolve();
console.log(2);
})
.then(() => {
console.log(3);
});
new Promise(resolve => {
resolve();
console.log(4);
})
.then(() => {
console.log(5);
});
setTimeout(() => {
console.log(6);
}, 0);
console.log(7);
console.log('#####');
// 1. new Promise时候马上执行
// 2. resolve或者reject之后状态不再改变,但后面代码会执行
// 3. 微任务队列为空,取宏任务队列中的一个任务开始执行,然后重复上一步,直到宏任务队列为空
// https://zhuanlan.zhihu.com/p/480120265
const promise = new Promise((resolve,reject)=>{
console.log(11);
resolve();
console.log(22);
reject();
});
setTimeout(()=>{console.log(55)},0);
promise.then(()=>{console.log(66)})
.then(()=>{console.log(66)})
.catch(()=>{console.log(88)});
console.log(99);
console