When several independent asynchronous tasks must finish before work can continue, Promise.all waits for every promise in an array. It fulfills with their results in input order, or rejects if any promise rejects. section 6.3.6
Listing 6.17. Waiting for a number of promises with Promise.all
Promise.all([getJSON("data/ninjas.json"), #A
getJSON("data/mapInfo.json"), #A
getJSON("data/plan.json")]).then(results => { #A
const ninjas = results[0], mapInfo = results[1], plan = results[2]; #B
#B
assert(ninjas !== undefined #B
&& mapInfo !== undefined && plan !== undefined, #B
"The plan is ready to be set in motion!"); #B
}).catch(error => {
fail("A problem in carrying out our plan!");
});
Three JSON requests gather ninja, map, and plan data in parallel; the next step uses their ordered results, with a catch for failure. section 6.3.6

