It is not possible to explain all of the key concepts in a single article. So this will be a 4 part series that helps you lay the foundation of the major concepts in Promises.
Up until this point, we have learned
Now we will look into some of the other methods in Promise API and when to use them.
Promise.all() method takes an iterable of promises as the input, and returns a single
This returned promise will only resolve when all of the input promises have resolved and its value will be an array of the results of the input promises.
If any of the input promises reject or throws an error, the returned promise will immediately…
In parts 1 and 2 of this series, we understood Why promises were introduced, What promises are, and how to create them. In this part, we will build on that by understanding how we can chain multiple promises together or simply Promise chaining.
This is an important concept to understand, one which is at the base of further asynchronous JS concepts like async/await.
Up until this point, we have only talked about a single asynchronous task being carried out. But what if, we have to do multiple asynchronous tasks in succession, each after the previous one finishes?
To understand that…
In part 1 of this series, we have understood why Promises were introduced. We know that the Promise API was introduced as a better paradigm to handle Asynchronous JS. Here we will understand What are promises and How to create promises with a simple example and we will, later on, look at a more practical example.
So what is a promise?
Imagine one morning at work, your colleague calls you up and asks you to do a favor. He needs you to go to the office parking lot and check whether there is an open spot. …
Loves JS, java and anything tech.