An ES6 Promise is an ECMAScript 2015 object that represents an in-progress asynchronous operation
An ES6 Promise is an ECMAScript 2015 (ES6) object that represents the eventual completion or failure of an asynchronous operation. The ES6 Promise API is based on the Promises/A+ specification.
Consumer-side, a promise is essentially a returned object to attach callbacks to, instead of passing callbacks into a function. The .then
function lets callers chain operations to be run subsequently.
In an ideal world, all asynchronous functions would return promises. However, a promise may also be created from scratch using its constructor, to wrap old callback-style function calls.
Promise objects have three possible states:
- Pending
- Fulfilled
- Rejected
Resources
- Using promises
- ECMAScript® 2015 Language Specification: 25.4.3 The Promise Constructor
- MDN: Promise
- Promises/A+ spec
- Exploring ES6: 25. Promises for asynchronous programming