Promises explained
JavaScript promises from the ground up: the three states, creating and consuming promises, chaining with then, error handling with catch and finally, Promise.all, allSettled, race and any, converting callbacks, async and await on top, and the common mistakes.
CodexBash, , 5 min read
Fetching data, reading files, waiting for a timer: much of JavaScript is asynchronous, and the promise is the object that represents all of it. A promise stands for a value that is not available yet but will be, or an error explaining why it never will be. Promises replaced deeply nested callbacks, and async/await is built directly on top of them, so understanding promises is the key to understanding modern JavaScript. This article explains how they work, with runnable examples.
Sign in to read the rest
The whole 5 minute article is free with an account, along with every problem, lesson and tutorial. No card.