What you’ll learn
- Synchronous vs asynchronous code
setTimeoutandsetInterval- Callbacks and the Pyramid of Doom
- Promises: pending, fulfilled, rejected
then,catchandfinallyasyncandawait- Running things in parallel with
Promise.all - Fetching real data from the internet
- How the event loop works
The pages
Ten pages, about 18 minutes.
- Synchronous vs Asynchronous Let's visit a restaurant. Restaurant A has a very strange waiter. He comes to your table and takes your order. Then he…
- Timers: setTimeout and setInterval The simplest way to see asynchronous code in action is with a timer. setTimeout(callback, delay) runs a function once…
- Callbacks and the Pyramid of Doom Before 2015, the main way to handle asynchronous tasks was with callbacks: you pass a function that should be called…
- Promises: An IOU for a Future Value Ever been to a restaurant where they give you a little buzzer when you order? The buzzer isn't your food. But it's a…
- async and await: Code That Reads Like a Story Promises were a huge improvement. But in 2017, JavaScript added something even nicer: async and await. They let you…
- Doing Things in Parallel: Promise.all Using await one after another runs tasks in sequence: each one waits for the previous one to finish. That's what you…
- Fetching Data From the Internet Now for the big payoff. All of this asynchronous stuff exists mainly so that JavaScript can do one incredibly…
- The Event Loop: How It All Works Okay, time for the big reveal. How does single-threaded JavaScript juggle timers, clicks and network requests all at…
- Mini Project: The Burger Kitchen Simulator Let's simulate a busy restaurant kitchen. Some steps must happen in order, some can happen at the same time, and…
- Recap The key ideas of Freshman Year, Asynchronous JavaScript, on one page. Synchronous code runs one line at a time…
Reading is step one
CurlyScript turns these notes into a game: short questions, an explanation after every answer, and a test at the end of each grade. Free, with nothing to sign up for.