← JavaScript learning pathJavaScript · Module 9 of 10
Asynchronous JavaScript
Handle slow work like network calls with callbacks, promises and async/await.
📖 Key ideas
- JavaScript runs one thing at a time but does not wait for slow tasks; it continues and comes back later.
- setTimeout(fn, 1000) runs fn after a delay.
- A Promise represents a value that arrives later: then() and catch().
- async/await makes promise code read top to bottom.
- 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