-2

What are the pros and cons of using the async/await pattern vs promises in JavaScript?

Why would I use one and not the other?

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
Scott Jungwirth
  • 6,105
  • 3
  • 38
  • 35

1 Answers1

4

There's a fundamental misunderstanding, you cannot use one (async/await) without the other (promises). They are not alternatives.

The alternative is between using promises with .then() callbacks, and using promises with neater await syntax. The difference is entirely syntactical, not functional, so you need to weight readability (maintainability) against syntax support (possible tooling necessity).

Bergi
  • 630,263
  • 148
  • 957
  • 1,375