Question presented to candidate: "You have a slow operation that finishes after a delay. Show me the same operation handled three genuinely different ways — and explain whether they're fundamentally different mechanisms, or just different syntax for the same thing underneath."
What a strong answer should cover:
- 📌 Interview term: callbacks — the original, foundational approach: passing a function to be called once the async work completes — verified directly, still the real underlying mechanism every other approach genuinely builds on.
- 📌 Interview term:
.then()chaining — Promises (covered in this bank's own dedicated Promise-states question) wrap a callback-based operation in a more composable, chainable object. - 📌 Interview term:
async/await(covered in this bank's own dedicated question) — syntax that lets Promise-based code be WRITTEN in a synchronous-looking style, while still genuinely running asynchronously underneath. - 📌 Interview term: the real, direct answer to the prompt — verified directly: the identical delayed task, run through all three approaches side by side, genuinely produces the same real result — confirming they are different SYNTAX over the same underlying event-loop/task-queue mechanism, not three fundamentally different ways of achieving concurrency.
- A precise answer names the real, practical trade-offs each style has: callbacks genuinely risk deep nesting ("callback hell") for sequential dependent operations;
.then()chaining flattens that nesting but still requires an explicit.catch()for errors;async/awaitgenuinely reads most like synchronous code and lets a plain try/catch handle errors, at the real cost of needing to be careful about accidentally serializing genuinely-independent operations (covered in this bank's own async/await question) instead of usingPromise.all.
Clarifying questions expected:
- None — this is a definitional/survey question; directly answering whether the three approaches are fundamentally different (they're not — same underlying mechanism) is the strong signal.
Code / implementation expected: Yes — the identical delayed operation, genuinely run through all three approaches side by side, is the clearest, most convincing demonstration that they're the same mechanism underneath.