JavaScript 运行原理解析
作者:
TingsLee | 来源:发表于
2018-10-29 11:23 被阅读0次
关于Js的运行原理,《JavaScript 运行原理解析》这篇文章写的很易懂,而且想要了解更深入,文章的参考链接都值得细读
关键知识点:
事件循环(Event Loop)和事件队列(Callback Queue)和调用栈(Call Stack)之间的关系:
Event Loop只做一件事情,负责监听Call Stack和Callback Queue。当Call Stack里面的调用栈运行完变成空了,Event Loop就把Callback Queue里面的第一条事件(其实就是回调函数)放到调用栈中并执行它,后续不断循环执行这个操作,这就是事件循环。
console.log('Hi');
setTimeout(function cb1() {
console.log('cb1');
}, 5000);
console.log('Bye');
事件循环
参考链接:
- How JavaScript works: Event loop and the rise of Async programming + 5 ways to better coding with async/await
- How JavaScript works: an overview of the engine, the runtime, and the call stack
- Philip Roberts: What the heck is the event loop anyway?
- Tasks, microtasks, queues and schedules
本文标题:JavaScript 运行原理解析
本文链接:https://www.haomeiwen.com/subject/jzfbtqtx.html
网友评论