乐趣区

Promiseall和Promiserace实现

Promise.all=(proArr) =>{return new Promise((resolve, reject) => {let retsult = []
        let count = 0
        for (let i = 0; i < proArr.length; i++) {proArr[i].then(data => {retsult[i]=data
                if(++count===proArr.length){resolve(retsult)
                }
            }, reject)
        }
    })
}
Promise.race=(promiseAry)=> {return new Promise((resolve, reject) => {for (let i = 0; i < promiseAry.length; i++) {promiseAry[i].then(resolve, reject)
      }
    })
  }
退出移动版