Collection of front-end interview skills Part 4: Advanced part 2

This is a record 前端面试的话术集锦第四篇博文——进阶篇下and I will keep updating this blog post. ❗❗❗

1. What is the difference between browser Eventloop and Node?


As we all know JS, it is a non-blocking single-threaded language because JSit was originally created to interact with browsers.

If JSit is a multi-threaded language, DOMproblems may occur when we process it in multiple threads (new nodes are added in one thread and nodes are deleted in another thread). Of course, read-write locks can be introduced to solve this problem. question.

JSDuring the execution process, execution environments will be generated, and these execution environments will be added to the execution stack sequentially. If it encounters asynchronous code, it will be suspended and added to Task(there are multiple task) queues.

Once the execution stack is empty, the code that needs to be executed Event Loopwill be taken out from the queue and put into the execution stack for execution. TaskSo essentially, JSasynchronous in is still synchronous behavior.

console.log('script start');

setTimeout<

Guess you like

Origin blog.csdn.net/lvoelife/article/details/132612581