O'Reilly logo

JavaScript Promises Essentials by Rami Sarieddine

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Why should I care about promises?

What do promises have to do with all of this? Well, let's start by defining promises.

 

A promise represents the eventual result of an asynchronous operation.

 
 --Promises/A+ specification, http://promisesaplus.com/

So, a promise object represents a value that may not be available yet, but will be resolved at some point in the future.

Promises have states and at any point in time, can be in one of the following:

  • Pending: The promise's value is not yet determined and its state may transition to either fulfilled or rejected.
  • Fulfilled: The promise was fulfilled with success and now has a value that must not change. Additionally, it must not transition to any other state from the fulfilled state.
  • Rejected: The promise is ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required