When making multiple requests concurrently with Promise.allSettled, does the order of the array in the response correspond to the intitial array in the request? Does it maintain the same order regardless of the order in which they settle?
const promise1 = new Promise((resolve, reject) => setTimeout(resolve, 2000, 1)); //finish last
const promise2 = Promise.resolve(2); //finish first
const promise3 = new Promise((resolve, reject) => setTimeout(resolve, 100, 3)); //finish in the middle
const promises = [promise1, promise2, promise3];
Promise.allSettled(promises).
then((results) => results.forEach((result) => console.log(result)));
In testing it seems to be true, but there seems to be no guarantee in the documentation that the order will remain. The MDN docs are here