Introduction to JavaScript Promises

Get introduced to JavaScript promises.

We'll cover the following


One of the most powerful aspects of JavaScript is how easily it handles asynchronous programming. As a language created for the web, JavaScript needed to respond to user interactions, such as clicks and key presses, from the beginning, so event handlers such as onclick were created.

Event handlers allow developers to specify a function to execute at some later point in time in reaction to an event.

Node.js further popularized asynchronous programming in JavaScript by using callback functions in addition to events. As more and more programs started using asynchronous programming, events and callbacks were no longer sufficient to support everything developers wanted to do. Promises are the solution to this problem.


A promise specifies some code to be executed later (as with events and callbacks) and explicitly indicates whether the code succeeded or failed at its job. We can chain promises based on success or failure, in ways that make our code easier to understand and debug. Promises work like future and deferred in other languages.