函数调用形成了一个栈帧
按函数调用的先后顺序入栈,函数返回时出栈
对象被分配在一个堆中,即用以表示一大块非结构化的内存区域
If the stack is clear and there's something in the queue, push the first thing on the queue on to the stack
每次执行栈空了之后都会去队列中取第一个消息执行,队列中的消息都关联着一个用以处理这个消息的函数
- 函数执行时不会被抢占
- 消息添加若没有关联函数消息会丢失
- 零延迟的回调需要排队
同步任务(synchronous)
异步任务(asynchronous)
执行栈(execution context stack & call stack)
任务队列(task queue)
To be continued
- setTimeout
- setInterval
- setImmediate
- requestAnimationFrame
- I/O
- UI rendering
- process.nextTick
- Promises
- Object.observe
- MutationObserver
处理异步通常通过事件和回调进行,除了alert 和同步 XHR