前端杂谈: 如何实现一个 Promise?
前端杂谈: 如何实现一个 Promise? 首先, 什么是 Promise? A promise is an object that may produce a single value some time in the future: either a resolved value, or a reason that it’s not resolved (e.g., a network error occurred). A promise may be in one of 3 possible states: fulfilled, rejected, or pending. Promise users can attach callbacks to handle the fulfilled value or the reason for rejection. 关键语句: Promise 是一个在将来某个时刻产生一个单一结果的对象.通俗一点来说, Promise 代表了一个值, 但是这个值我们并不确定什么时候会被返回. A promise is an object that may p...