programming

JavaScript Best Practices — Promises

 

If we want to run multiple unrelated promises at once, then we should use .

For instance, we can run them all at once as follows:

If we use and , we can write:

In both examples, the resolved values of all three promises are either in or assigned to an array on the left (in the second example).

This way, they run all at once instead of waiting for each to resolve.

Share This Post To Your Friends

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *