Skip to content
Daily learningJavaScript

await null still yields

Awaiting a non-promise does not resolve synchronously.

2 min
Share

A common assumption is that await on a non-promise is a no-op. It is not.

async function run() {
  console.log('a')
  await null
  console.log('c')
}

run()
console.log('b')
// a, b, c

await always suspends. The operand is wrapped, and everything after it is scheduled as a microtask — whether you awaited a promise, a number, or null.

The practical consequence: adding an await to a function changes the ordering of code that never touched promises. That is usually harmless and occasionally the explanation for a bug that appeared when someone made a function async.

One useful email a month

Design system patterns, front-end techniques and case study breakdowns. No promotions, no digest of other people's links.

Unsubscribe anytime. We never share your address.