Question presented to candidate: "Does an async function ALWAYS return a Promise, even if the function body never uses await at all? And if you await two things back to back, do they run one after another, or at the same time?"
What a strong answer should cover:
- 📌 Interview term:
async function— always returns a real Promise, no matter what the function body does — verified directly: anasync functionwith literally noawaitin its body genuinely still returns a real Promise object, not a plain value. - 📌 Interview term:
await— genuinely pauses the async function's execution at that exact line, resuming only once the awaited Promise settles — verified directly with a real, ordered array of pushes, confirming code AFTER calling an async function (but beforeawaiting its result) genuinely runs before the awaited line resumes. - 📌 Interview term: the real, direct answer to the prompt's sequencing question — verified directly, with a real, measured elapsed time: two sequential
awaits genuinely run in series, one after another — NOT concurrently — a real two-step 30ms-each delay measured a genuine ~68ms total, not ~30ms, confirming the secondawaitgenuinely does not start until the first one has fully resolved. - 📌 Interview term: errors inside an async function become rejections — verified directly: a value thrown inside an
async functiongenuinely becomes a real rejected Promise, catchable with an ordinary try/catch wrapped around theawait— the same real mechanism this bank's own dedicated Promise-states question covers for a thrown error inside.then(). - A precise answer names that
awaiton a plain, non-Promise value genuinely just resolves immediately with that value — verified directly — and thatasync/awaitis fundamentally syntax sugar over Promises, not a genuinely different underlying mechanism.
Clarifying questions expected:
- None — this is a definitional/technical question; directly answering both halves of the prompt (always-returns-a-Promise, and series-not-concurrent) with real proof is the strong signal.
Code / implementation expected: Yes — the real, timed proof that two sequential awaits run in series (not concurrently) is the clearest, most convincing demonstration.