Await vs Then: Readability Trade-offs
You'll learn: How await and .then() differ in readability and when the "synchronous-looking" style might hide important details about promise behavior.
The Readability Advantage
await makes async code look almost identical to synchronous code. Instead of chaining .then() calls, you write sequential statements that "wait" for results. This is often easier to read and reason about:
// With .then()
fetchUser(id)
.then(user => fetchOrders(user.id))
.then(orders => processOrders(orders))
.catch(err => console.error(err));
// With await
async function getAndProcessOrders(id) {
const user = await fetchUser(id);
const orders = await fetchOrders(user.id);
await processOrders(orders);
}
The await version reads like a story: "Get the user, then get their orders, then process them."
The Trade-off: Hiding the Promises
However, this readability comes with a subtle cost. await obscures the fact that you're working with promises. New developers might forget:
- Each
awaitpauses execution and returns control to the event loop - You're still dealing with async operations (not truly synchronous)
- The underlying promise chain is still there, just hidden
With .then(), the promise nature is explicit—you see the chain, you remember you're dealing with async flow. With await, code looks synchronous but behaves asynchronously.
When Does This Matter?
When debugging timing issues, understanding the microtask queue, or optimizing concurrent operations, the "magic" of await can make it harder to see what's actually happening under the hood.
Key Takeaway: await dramatically improves readability by making async code look synchronous, but this convenience can obscure the underlying promise mechanics—remember you're still working with async operations even when the syntax feels linear.