Skip to content Skip to sidebar Skip to footer

Can Promise.all Take In An Array Of All Non-promise Elements?

Promise.all resolves when all the promises in its array resolves, but there is an example where an element of the input array is not a promise https://developer.mozilla.org/en/docs

Solution 1:

Promise.all calls Promise.resolve on all of the argument elements before doing anything with them. For those that already are promises, nothing happens; for thenables, they'll be converted to a proper promise, and everything else will get wrapped in a fulfilled promise.


Post a Comment for "Can Promise.all Take In An Array Of All Non-promise Elements?"