← Node.js & Express learning path
Node.js & Express · Module 3 of 10

Async JavaScript in Node

Handle files, timers and network calls with callbacks, promises and async/await.

📖 Key ideas

  1. Callbacks were the original async style (error-first: (err, data)).
  2. Promises represent a future value.
  3. async/await makes async code read like normal code.
  4. Wrap await in try/catch to handle errors.
  5. Promise.all runs tasks in parallel.
💡 Real-life example: async/await is ordering food with a buzzer: you sit down and are called when it is ready.
CallbackFunction called when work finishes
PromiseObject for a future result
awaitPauses until a promise settles
Promise.allWaits for several promises together