Advance JavaScript Course
About Lesson

The Promise.all() method is actually a method of the Promise object (which is also an object under JavaScript used to handle all the asynchronous operations), that takes an array of promises(an iterable) as input. It returns a single Promise that resolves when all of the promises passed as an iterable, which have resolved, or when the iterable contains no promises. In a simple way, if any of the passed-in promises reject, the Promise.all() method asynchronously rejects the value of the promise that has already been rejected, whether or not the other promises have been resolved.

Parameters: This method accepts a single parameter iterable which takes an array of promises or a normal array that contains some objects.

Return values: It follows some rules to return a single promise: 

  • If passed argument is empty, it returns a Promise that is already resolved.
  • If the passed iterable contains no promises, it returns a Promise that is resolved asynchronously.
  • For all other cases, it returns a pending Promise.
Fulfillment and Rejection of Promise.all() Method: 

Fulfillment: The returned promise is fulfilled, 

  • If the passed iterable is empty, then this method returns a promise synchronously which is already resolved.
  • If all of the passed promises are fulfilled, the returned Promises are fulfilled asynchronously.
  • Here the successful execution of this particular method totally depends on all promises to get successfully executed.

Rejection: If any of the passed promises are rejected, then this method rejects the value of that promise, whether or not the other promises have been resolved. In other words, if any promise fails to get executed, then Promise.all() method will return an error and it will not take into account whether other promises are successfully fulfilled or not.

Exercise Files
No Attachment Found
No Attachment Found
Join the conversation

Introducing Official ApeStaking Protocol for ApeCoin.

New Blur NFT Marketplace Courting Professional.