interview-answe icon indicating copy to clipboard operation
interview-answe copied to clipboard

236.[nodejs]node的事件循环和浏览器的事件循环有什么区别?

Open webVueBlog opened this issue 5 years ago • 1 comments

[nodejs]

webVueBlog avatar May 22 '20 22:05 webVueBlog

浏览器环境下:

while (true) {
    宏任务队列.shift();
    微任务队列全部任务();
}

Node 环境下:

while (true) {
    loop.forEach((阶段) => {
        阶段全部任务();
        nextTick全部任务();
        microTask全部任务();
    });
    loop = loop.next;
}

webVueBlog avatar May 22 '20 22:05 webVueBlog