#7 most askedVery commonMediumAsync & promises
Promises vs async/await
🏢 Asked in real interviews
No reports yet. Were you asked this? Be the first to say where.What is a Promise, and how does async/await relate to it? How do you handle errors with each?
🎤 Answer it out loud, then check yourself
Say your answer as if the interviewer is listening (30–90 seconds). Then reveal what a strong answer covers and tick what you said.
const wait = (ms, v) => new Promise((r) => setTimeout(() => r(v), ms));
async function sequential() {
const a = await wait(30, "a");
const b = await wait(30, "b");
return a + b;
}
async function parallel() {
const [a, b] = await Promise.all([wait(30, "a"), wait(30, "b")]);
return a + b;
}
let t = Date.now();
await sequential();
console.log("sequential ms ≈", Math.round((Date.now() - t) / 10) * 10);
t = Date.now();
await parallel();
console.log("parallel ms ≈", Math.round((Date.now() - t) / 10) * 10);
Answer out loud first, then compare.
Want to rehearse it?Answer this to the AI interviewer and get a verdict →