- Home
- /
- Tutorials
- /
- JavaScript Tutorial
- /
- JavaScript Promise.all
JavaScript Asynchronous
JavaScript Promise.all
Promise.allwaits for several promises at once instead of one after another.
Awaiting in a loop runs the work one at a time.
When the jobs do not depend on each other, that is wasted waiting.
Example
Example
javascript
const a = Promise.resolve(1);
const b = Promise.resolve(2);
Promise.all([a, b]).then(function (values) {
console.log(values.join(","));
});