构造函数Promise接收一个函数作为参数,这个函数又有两个函数参数resolve、reject
Promise对象存在三个状态:
Pending(进行中)Fulfilled(已成功)Rejected(已失败)
constructor 构造函数:
this._status = PENDING // 状态this._value = undefinedthis._fulfilledQueues = [] // 添加成功回调函数队列this._rejcetedQueues = [] // 添加失败回调函数队列try {handle(this._ressolve.bind(this), this._reject.bind(this))} catch (e) {this._reject(e)}
Promise then方法
then方法必须返回一个新的promise对象,所以promise支持链式调用
