The code below works for me
Promise.all([first, second, third]).then([first, second, third] => {
console.log(second);
});
I know that console.log(second)
will give me the value with the key second
.
My promises are dynamically set and now it looks like below:
let collection = [second, third];
Promise.all(collection).then((collection) => {
console.log(collection);
});
- In this example I set two values in collection. In real life it can include more or less values.
- When I use
console.log(collection)
it will outputcollection[0]
andcollection[1]
. In this case I don't know what which valuecollection[1]
is.
Question
How can I, like my first example, have something like named dynamically arguments like collection['second']
or similar?