JavaScript Promises In 10 Minutes




ES6 came with many new features, but one of the best features was the official introduction of Promises. Promises allow you to write clean non-callback-centric code without ever having to worry about callback hell. Even if you never write your own promise, knowing how they work is incredibly important, since many newer parts of the JavaScript API use promises instead of callbacks. Checkout the full video to learn how to define and use promises.

Code From This Video:

Twitter:

GitHub:
https://github.com/WebDevSimplified

CodePen:
https://codepen.io/WebDevSimplified

#JavaScript #Promises #WebDevelopment

Original source


38 responses to “JavaScript Promises In 10 Minutes”

  1. I’ve commented before, basically the same thing, but I REALLY enjoy your style of teaching. To the point, understandable examples, and clean code. This is by far the best video on Promises I’ve seen yet. Thank you!

  2. Hi there, great video!

    Just a clarification from what I understood reading https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise , apparently the New Promise starts running its code as soon as it's defined ("the executor is called before the Promise constructor even returns the created object") so when you say that Promise.all will run the promises, from my understanding what actually happens is that every Promise gets executed at the moment they are created and Promise.all constantly checks if all are done. It's a matter of sequence, the Promise.all doesn't actually executes but waits for the results…

  3. Hi, Could you please make a video explaining the auto completion information in visual studio code. A break down of that would be useful. I mean all the information that comes with a method, constructor etc. Generally I understand the concept, but I have to remind myself sometimes. I think people might benefit from it.

  4. Fantastic explanation! My only feedback is to increase the font size in your editor for those of us watching on mobile (and I'm sure desktop would benefit) when doing these smaller examples. Would be a lot easier to read.

  5. Thx for the video, but I believe this is not completed. The exist of promise is to resolve callback hell. The video should explain more about this. And more important, async/await is missed out in this video. That's a very strong reason to use promise. From a async function, the promise will be returned implicitly. Using await can make your code a lot cleaner then using callback. That's the standard use case of promise.

  6. youtube.addEventListener('load', () => {
    checkOut(recommended());
    });

    async function checkOut(video) {
    let result = await watch(video);
    if (result.channel=== 'Web Dev Simplified') { like(); comment(); return next(); }
    close();
    }

Leave a Reply