Grokking Advanced JavaScript
0% completed
Promise Chaining
Calling then on a promise does two things. It registers a handler, and it returns a new promise that settles after the handler has run. The next few lines check the second part:
false true second fulfilled with 2
second is a different promise from first, and it was fulfilled with 2, the value that the handler returned. Because then returns a promise, you can call then again on the result, and again on that result. A sequence of then and catch calls connected in this way is a promise chain
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%