← JavaScript learning path
JavaScript · Module 9 of 10

Asynchronous JavaScript

Handle slow work like network calls with callbacks, promises and async/await.

📖 Key ideas

  1. JavaScript runs one thing at a time but does not wait for slow tasks; it continues and comes back later.
  2. setTimeout(fn, 1000) runs fn after a delay.
  3. A Promise represents a value that arrives later: then() and catch().
  4. async/await makes promise code read top to bottom.
  5. Use try/catch with await to handle errors.
💡 Real-life example: Ordering food at a restaurant: you get a token (promise), sit down, and your food arrives later without you standing at the counter.
PromiseA value that will arrive later
awaitWaits for a promise inside async functions
setTimeoutRuns code after a delay
catchHandles a rejected promise