What Makes Async Functions Different?

Distinguish between asynchronous and synchronous functions.

Async functions are different from synchronous functions in four ways:

  • The return value is always a promise.
  • Thrown errors are promise rejections.
  • The await expression can be used.
  • The for-await-of loop can be used.

These four aspects of async functions make them quite different from synchronous ones, so it’s worth going through each point in more detail.

The return value is always a promise

We can use the return operator in async functions the same way as in synchronous functions. The difference is that async functions always return a promise, regardless of the type of value we specify with return. If we return a number, for example, that number is wrapped in a promise:

Get hands-on with 1200+ tech skills courses.