场景题:事件循环机制(字节跳动面试题)

    科技2022-07-21  100

    执行顺序见标注

    async function async1 () { console.log('async1 start');//2 await async2(); console.log('async1 end');//7 } async function async2 () { console.log('async 2');//3 } console.log('script start');//1 setTimeout(() => { console.log('setTimeout');//8 }, 0); async1(); new Promise((resolve) => { console.log('promise 1');//4 resolve(); }).then(() => { console.log('promise 2');//6 }) console.log('script end');//5
    Processed: 0.010, SQL: 8