Handling multiple async operations in Javascript with Promise.all()

in #javascript7 years ago

Here is a simple javascript promise operation that demonstrates the handling of multiple async operations with the Promise.all() method.

In the code, I am only showing the resolved results, but you can add a condition to reject the promise and see what happens:

PromiseAll.png

You can see I had created two functions to add and subtract numbers. The add is called after 100ms and the sub is called after 1200ms. But we get our response after both have been resolved.

Hope this helps!

Coin Marketplace

STEEM 0.20
TRX 0.12
JST 0.029
BTC 60320.14
ETH 3373.37
USDT 1.00
SBD 2.51