async functions return promises. await pauses until a promise settles—syntax reads like synchronous code.
Pattern
Wrap await in try/catch for errors. Parallel work: await Promise.all([a(), b()]).
async returns
Returning a value wraps it in resolved promise—throwing rejects the promise.
Important interview questions and answers
- Q: await in loop?
A: Sequential—slow for independent requests; use Promise.all. - Q: async without await?
A: Still returns Promise—useful for uniform APIs.
Self-check
- How run two fetches in parallel?
- What does async function return?
Tip: Promise.all for parallel independent requests.
Interview prep
- Parallel fetch?
Promise.all with multiple awaits.