How to Use Javascript Promises




This screencast explains the Javascript Promise pattern at a very high level. Promises are a fundamental tool for modern Javascript development, but it’s easy to get overwhelmed when first starting out.

All of the code is pseudo-code meant to make the concept of Promises easier to understand. In a real code base you probably want to use a promise library such as Q or Bluebird instead of using the native Javascript deferred object.

Original source


44 responses to “How to Use Javascript Promises”

  1. Hey, could I talk to you? I am new to JS let alone ES6 but I need to store and get JSON information and use the objects for logic and view. I'm a little over my head. Trying not to bloat up with libs and I think this maybe the solution. Everything will be localStorage or hardcoded.

  2. before understanding promises and defered, i saw ur tutorial and got confused, but after knowing about it, when i saw it again, you were talking right lol

  3. I am just starting to see the video but run into errors in console, why chrome console is throwing error in my case
    var deferred = Promise.defer()
    VM424:1 Uncaught TypeError: Promise.defer is not a function
    at <anonymous>:1:24

  4. Watched a bunch of videos and still had no idea what Promises were and how they worked. Watched YOUR video and I GOT IT!!!! You did a spectacular job explaining how it worked and how to use it in different situations. Thank you for you video.

  5. awesome explanation …. most people explain promises in very dry and abstract manner…. what make this tutorial standout is will thought off real world uses of promises and the examples …. this indeed the best video on promises out there ….. thanks so much and please keep up ….

  6. Are you using the normal DevTool console from chrome? when i try the same code like:

    var d1 =Promise.defer()

    it says that "VM390:1 Uncaught TypeError: Promise.defer is not a function
    at <anonymous>:1:17"

    what am i doing wrong?

  7. what JavaScript framework do you recommend learning right now? I'm in the fence with angular2 and react: I'll prob learn both, but if you had to pick one to start with.. which would you pick? And then, what about the backend..?

  8. You explained the whole deferred and promise thing in such a simple way. Thank you sir. Though some of the methods used are obsolete now, but is a good stepping stone to understand the new style.

Leave a Reply