Promises are an abstraction of the flow of program execution which can be summed up as follows:

  • Asker: Whenever you’re done doing what you’re doing, would you call me back?
  • Answerer: Sure thing, I promise

A JavaScript Promise can be:

  • fulfilled - the action relating to the promise succeeded
  • rejected - the action relating to the promise failed
  • pending - hasn’t been fulfilled or rejected yet
  • settled - has fulfilled or rejected

Simple Promise

Complex Promise - Promisfying an XMLHttpRequest

Sugar Coating Error Handling

Chaining then()‘s