async function async1() {
console.log('async1 start'); // 2
await async2();
console.log('async1 end'); // 7
}
async function async2() {
console.log('async2'); // 3
}
console.log('script start'); // 1
setTimeout(function (){
console.log('setTimeout'); // 9
}, 0)
async1();
new Promise(function (resolve) {
console.log('promise1'); // 4
resolve();
console.log("???"); // 5 这一句是我自己加的,目的考察大家是否知道同步代码和微任务,迷惑大家resolve()后面是否还会执行
}).then(function() {
console.log('promise2'); // 8
})
console.log('script end'); // 6