What is async/await in Node.js?
Why Interviewers Ask This
Interviewers use this question to quickly assess whether a candidate has the foundational knowledge required for Node.js development. It reveals whether you understand the building blocks that more complex concepts rely on.
Answer
async/await is syntactic sugar built on top of Promises that allows you to write asynchronous code in a synchronous, sequential style. Mark a function with the async keyword — it automatically returns a Promise. Inside an async function, use await before any expression that returns a Promise; execution pauses at that point until the Promise settles, then resumes with the resolved value. Error handling uses standard try/catch/finally blocks, which is more intuitive than .catch() chains. Example: async function fetchUser(id) { try { const data = await db.find(id); return data; } catch (err) { console.error(err); } }. Important: await only suspends the current async function, not the entire Node.js event loop — other events continue to be processed. For parallel operations, use await Promise.all([...]); instead of sequential awaits.
Common Mistake
Candidates often give textbook answers here. Interviewers are more impressed when you relate the concept to a specific problem you solved in a real Node.js project.