# 如何实现 Promise.race

Issue

欢迎在 Issue 中交流与讨论: Issue 314 (opens new window)

Author

回答者: codelou (opens new window)

Promise.race = function (promises) { return new Promise((resolve, reject) => { promises.forEach((p,index) => { Promise.resolve(p).then( value => {resolve(value)}, reason => { reject(reason) } ) }) }) }

Last Updated: 1/15/2021, 6:07:33 AM