chrome 消息队列的执行顺序

渲染进程

微队列(最高优先级),如异步请求
交互队列(高优先级),如点击事件
延时队列 (中优先级),如setTimeout


// eg.

function a() {
    console.log(1);

    Promise.resolve().then(() => {
        console.log(2);
    })
}

setTimeout(() => {
    console.log(3)
}, 0);

Promise.resolve().then(a);

console.log(4);



// 输出 4 1 2 3

posted @ 2022-11-17 23:01  进阶的哈姆雷特  阅读(47)  评论(0编辑  收藏  举报