Async & event loop · Concept
async/await semantics and error handling
Practise this out loud
Say your answer out loud to an AI interviewer that follows up, and get a score for it.
Practise by voiceThe interviewer asks
What does async/await compile down to conceptually? How do you handle errors, run things in parallel, and avoid accidental waterfalls?
Then
Follow-ups the interviewer asks next
awaitin aforloop vsPromise.all(items.map(...)). When is sequential correct?- What happens to an unhandled rejection in the browser vs Node?
return promisevsreturn await promiseinside try/catch (see Output section).- Top-level await in ESM and its effect on module loading.
The answer
What a strong answer covers
- An async function always returns a promise;
awaitsuspends and resumes in a microtask - try/catch around awaits;
.catchon the returned promise;Promise.allSettledfor partial failure - Start promises first, then await them, to parallelise
- Unhandled rejections: the
unhandledrejectionevent in browsers; recent Node versions crash the process by default
The red pen
Common traps
Avoid:"await blocks the thread"; wrapping everything in one try/catch and swallowing errors.
Practise this out loud
Say your answer out loud to an AI interviewer that follows up, and get a score for it.
Practise by voicePractise questions like this out loud
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.