O'Reilly logo
live online training icon Live Online training

Impatient JavaScript: Async Programming

An introduction into JavaScript Promises and Async/Await

Topic: Web & Mobile
Cay Horstmann

When you program in JavaScript, you never want to wait. To keep your user interface or backend program moving along, each action should do its task as quickly as possible and return. You can't afford to linger until data arrives from a remote source. That means callbacks, and often callbacks inside callbacks. To avoid "callback hell," modern JavaScript has promises and the aysnc/await syntax. In this short course, you will learn how these constructs work. We go into sufficient detail that you can actually understand what goes on under the hood, instead of just sprinkling async and await keywords over your code and hoping for the best.

What you'll learn-and how you can apply it

When you complete this live online course, you'll understand

  • The single-threaded execution model of JavaScript
  • Callbacks and their limitations
  • How to construct promises
  • How to work with promises that someone makes to you
  • The async syntax for functions that make promises
  • The await syntax for waiting for promised values

And you'll be able to

  • Write concise and comprehensible JavaScript code for asynchronous tasks
  • Understand the pitfalls of asynchronous programming in JavaScript
  • Use your knowledge of promises to use async/await correctly

This training course is for you because...

  • You are an experienced JavaScript programmer
  • You want to learn modern asynchronous programming in JavaScript with a minimum of fuss


  • Comfortable with modern JavaScript
  • Familiar with arrow functions and exception handling

Course Set-up

  • The development tools in Chrome or Firefox suffice, but you may want to install node.js for a more comfortable experience.

Recommended Preparation

  • Modern JavaScript for the Impatient (Book), Cay Horstmann (Available July 2020)

Recommended Follow-up

About your instructor

  • Cay Horstmann grew up in Northern Germany and attended the Christian-Albrechts-Universität in Kiel, a harbor town at the Baltic sea. He received a M.S. in computer science from Syracuse University, and a Ph.D. in mathematics from the University of Michigan in Ann Arbor. For four years, Cay was VP and CTO of an Internet startup that went from 3 people in a tiny office to a public company. Cay now teaches computer science at San Jose State University and held visiting appointments at universities in Switzerland, Vietnam, and Macau. In his copious spare time Cay write books and articles on programming languages and computer science education.



The timeframes are only estimates and may vary according to how the class is progressing

Introduction (5 min)

Concurrent Tasks in JavaScript (15 min)

  • Single-threaded execution model
  • Callbacks and callback hell

Making Promises (20 min)

  • The Promise constructor and the executor function
  • Immediately settled promises

Processing Promise Results (30 min)

  • Waiting for settlement
  • Chaining promises
  • Rejection handling
  • All and any

The Concept of Async Functions (30 minutes)

  • The await keyword
  • Declaring async functions
  • The red pill and the blue pill
  • What goes on under the hood
  • Normal and exceptional return

Advanced Topics (25 min)

  • How to decide between promises and async/await
  • How to work through confusing scenarios
  • How promises are implemented
  • Async generators

Conclusion (5 min)