A Promise represents the result of an operation that hasn't been completed yet, but will at some undetermined point in the future. An example of such an operation is a network request. When we fetch data from some source, for example an API, there is no way for us to absolutely determine when the response will be received.
Without Promises, we would have to use callbacks to deal with actions that need to happen in sequence. This isn't necessarily a problem if we only have one asynchronous action. But if we need to complete multiple asynchronous steps in sequence, callbacks become unmanageable and result in the infamous callback hell.
Example usage:
doSomething() // This returns a Promise
.next(doSomethingElse)
.error(handleError)
.next(doMoreStuff)
.next(doFinalThing)
.error(handleAnotherError)
Create a promise by calling:
var myPromise = new Promise(function() {
// your async code here
})
End User Licence Agreement (EULA).