摘要: 基于ES6语法手写promise A+ 规范,源码实现 class Promise { constructor(excutorCallBack) { this.status = 'pending'; this.value = undefined; this.fulfilledAry = []; th 阅读全文
posted @ 2019-12-05 17:42 小提莫~ 阅读(850) 评论(3) 推荐(0) 编辑
摘要: 当我们执行 JS 代码的时候其实就是往执行栈中放入函数,那么遇到异步代码的时候该怎么办?其实当遇到异步的代码时,会被挂起并在需要执行的时候加入到 Task(有多种 Task) 队列中。一旦执行栈为空,Event Loop 就会从 Task 队列中拿出需要执行的代码并放入执行栈中执行,所以本质上来说 阅读全文
posted @ 2019-12-05 16:33 小提莫~ 阅读(2227) 评论(0) 推荐(0) 编辑