Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Introduction to JavaScript Promises in Depth

    Marius SchulzMarius Schulz

    Here’s an overview of all the topics we’re going to cover. Enjoy the course!



    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson




    Instructor: In this course, we're going to do a deep-dive on promises in JavaScript. Ever since they've been added to the language, promises have been an increasingly important building block for asynchronous operations.

    We're going to start off by looking at the different states that a promise can be in. We'll then put together our first promise chain using the then method. Next, we're going to look at how to catch errors in a promise chain.

    Throughout this course, we're going to focus a lot on error handling, as many asynchronous operations fail all the time. We're also going to learn how to use the finally method to run cleanup code in a promise chain no matter if there was an error or not.

    Next up, we're going to look at how to create a rejected promise using the Promise.reject method. We're then going to see how we can use the Promise.resolve method to convert any promise-like object to a proper native promise.

    Alternatively, we can create a new promise from scratch using the promise constructor. We're also going to explore Node.js' util.promisify helper, which lets us convert a callback-based function to one that uses promises.

    Towards the end of the course, we're going to learn how to work with multiple promises. We can call the Promise.race method to wait for the fastest promise to settle. Similarly, we can call the Promise.all method to wait for all promises to settle.

    Finally, we're going to learn how to use async functions and the await operator to write asynchronous code that is almost as easy to read as synchronous code. Thanks for watching and enjoy the course.