Promises vs async await
When do you prefer async/await over raw Promise chains? How do you run independent async work concurrently?
Answers use simple, clear English.
Quick interview answer
async/await improves readability and try/catch error handling for sequential flows. For independent tasks, use Promise.all / allSettled / race instead of awaiting one-by-one (which serializes and slows down). Always handle rejections.
Detailed answer
async/await improves readability and try/catch error handling for sequential flows. For independent tasks, use Promise.all / allSettled / race instead of awaiting one-by-one (which serializes and slows down). Always handle rejections.
Real example & use case
Page load fetches user and notifications in parallel with Promise.all, then renders.
Pros & cons
Pros: clearer control flow. Cons: accidental serial awaits hurt latency.
Code example
async function load(id) {
const [user, notes] = await Promise.all([
fetch('/api/users/' + id).then(r => r.json()),
fetch('/api/notes/' + id).then(r => r.json()),
]);
return { user, notes };
}Practice code · javascript (view only · no execution)
async function load(id) {
const [user, notes] = await Promise.all([
fetch('/api/users/' + id).then(r => r.json()),
fetch('/api/notes/' + id).then(r => r.json()),
]);
return { user, notes };
}