Let's Learn ES6
Chapter 17

Promises have been around for a while in JavaScript, but we have never had them in the language itself. In the past we would have had to use a library like q or bluebird. These libraries follow something called Promises/A+ , it is a standard that outlines how a Promise should behave, and it is the spec that ES6 Promises also implement.

A Promise represents the eventual result of some sort of asynchronous operation. Commonly these are used in conjunction with an HTTP request. However, it could actually just be any sort of event that will take some time to return. Promises can be a few different states. When a promise is created it has a 'pending' state. From there the Promise can have 2 other states, it can be fulfilled(commonly you will hear the word resolved used here), or rejected.

← Page-183 p.184 Page-185 →