...

/

Working with Multiple Promises: Racing Promises

Working with Multiple Promises: Racing Promises

Learn how JavaScript handles multiple promises by racing promises.

In the examples so far, promises were used to implement a single asynchronous task. In nontrivial scenarios, we may need multiple asynchronous tasks to be executed to solve a problem.

An analogy

A currency exchange broker may want to pick the best price quote from more than one provider. A promise carries the response for a single asynchronous task, but when dealing with multiple tasks, we need to combine data from multiple asynchronous functions, each returning a promise.

Handling multiple asynchronous functions

...