Learn JavaScript

Lesson 2 of 9 · Async 1: Callbacks and the Event Loop

Module 12 · Async 1: Callbacks and the Event Loop

Every Piece of the Async Toolkit: Timers, Clearing, Microtasks and Callback Shapes

Free with an accountReading

Nadia is building a small reminder tool for her team. A reminder must fire once after a delay, a clock must tick every second, and a "cancel" button must stop either one. A file read must report either an error or the data, never both.

Checking what this lesson needs for you…

What is inside Every Piece of the Async Toolkit: Timers, Clearing, Microtasks and Callback Shapes

  1. A callback is a function you hand over
  2. setTimeout: not before, never exactly
  3. The zero delay and Node's 1 ms floor
  4. clearTimeout cancels a waiting timer
  5. setInterval and clearInterval
  6. Extra arguments after the delay
  7. queueMicrotask
  8. The error-first callback
  9. A callback is called once
  10. Timers inside timers
  11. When does my callback run?