JavaScript callbacks, Promises, and async/await

Andrei Gec

By Andrei Gec

12 min read7 activities

... views · ... likes

Illustrated history of JavaScript asynchronous code progressing from nested callbacks to Promises and async/await.

JavaScript often starts work whose result will arrive later: fetching data, waiting for a timer, reading a file in Node.js, or asking a user for input. The language has not changed that underlying reality. What changed is how programs describe the work that should happen after a result arrives.

Callbacks made delayed work possible, Promises gave that work a standard value-like representation, and async/await made Promise-based code easier to read. These are not three separate asynchronous systems. Promise methods still register callbacks, and async/await builds on Promises.

What you will learn

You will learn how callbacks, Promises, and async/await represent asynchronous work, when operations remain sequential, how to introduce concurrency, and how to handle fetch failures correctly.

Activity

Overall knowledge check

Test the concurrency and error-handling distinctions that cause the most mistakes.

Question 1 of 1

What normally happens when fetch receives an HTTP 404 response?

Choose an answer.

Your gec.dev account

Keep learning on your terms

Signing in lets you:

  • Save activity progressResume learning activities across devices.
  • Choose notification emailsHear about new posts, filtered to your specific interests.