如何手写一个 Promise.all?
网友回复
// 自定义 Promise.all 的实现 function myPromiseAll(promises) { return new Promise((resolve, reject) => { let results = []; let count = 0; for (let i = 0; i < promises.length; i++) { promises[i].then((result) => { results[i] = result; count++; if (count === promises.length) { resolve(results); ...
点击查看剩余70%