We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Promise.all = function (arr) { // 实现代码 };
The text was updated successfully, but these errors were encountered:
Sorry, something went wrong.
Promise.all = function(promises) { let results = []; let promiseCount = 0; let promisesLength = promises.length; return new Promise(function(resolve, reject) { for (let val of promises) { Promise.resolve(val).then(function(res) { promiseCount++; // results.push(res); results[i] = res; // 当所有函数都正确执行了,resolve输出所有返回结果。 if (promiseCount === promisesLength) { return resolve(results); } }, function(err) { return reject(err); }); } }); };
No branches or pull requests
The text was updated successfully, but these errors were encountered: