The Promise.all
method doesn't have an index to target a particular promise so in my case, I'm wondering if I can do this:
let promises = [Promise.resolve(true),
Promise.resolve(true),
Promise.resolve(false),
Promise.resolve(true)];
Promise.all(promises).then(result => {
console.log(result);
// [true, true, false, true]
let failed = result.findIndex(r => !r);
console.log(promises[failed]);
});
Now this is assuming the order is always maintained, i.e the result array is always in the same sequence as the input array?