In JavaScript, how does async/await work, and how does it relate to Promises and callbacks?
technical-conceptual · Junior level · software-engineering
What the interviewer is really asking
Probes whether the candidate understands that async/await is built on Promises and writes readable asynchronous code rather than nesting callbacks.
What to say
- Trace the progression: callbacks were the original way to handle async work but nest into hard-to-read callback hell; Promises flattened that into chains; async/await is syntactic sugar over Promises that lets you write async code that reads top-to-bottom.
- Explain the mechanics: an async function always returns a Promise, and await pauses that function until the awaited Promise settles, without blocking the rest of the program because the event loop keeps running other work.
- Show good habits: wrap awaits in try/catch for error handling (the equivalent of .catch), and use Promise.all to run independent async tasks in parallel instead of awaiting them one after another.
What to avoid
- Saying await blocks the whole program or freezes the browser while it waits.
- Claiming async/await replaced Promises entirely, with no understanding that it's built on top of them.
- Awaiting independent operations sequentially in a loop when they could run concurrently.
Example answers
Strong: async/await is sugar over Promises: an async function returns a Promise, and await pauses just that function until the Promise resolves while the event loop keeps handling other work, so nothing freezes. It came out of callbacks, which nested into callback hell, then Promises that you chained with .then; async/await lets the same logic read top-to-bottom. I use try/catch to handle rejected Promises, and Promise.all when several calls are independent so they run in parallel instead of one at a time.
Weak: async and await make your code wait for something to finish before moving on, so it pauses the whole program until the data comes back. It's a totally new thing that replaced Promises, you don't really need Promises anymore once you have async/await. I just put await in front of anything that's slow and it handles it.