Search⌘ K
AI Features

Unsettled Promises

Explore how to create unsettled promises using the Promise constructor with an executor function that immediately runs, calling resolve or reject based on asynchronous events. Understand the timing of promise resolution, the role of microtasks, and how errors thrown inside executors trigger rejection handlers, preparing you to write more reliable asynchronous JavaScript code.

We'll cover the following...

Creating unsettled promises

New promises are created using the Promise constructor. This constructor accepts a single argument: a function called the executor, which contains the code to initialize the promise. The executor is passed two functions, resolve() and reject(), as arguments. When the executor has successfully finished, we call the resolve() function to signal that ...