2 ms·
It's not much more clear, but it is a standard, which has many advantages: - Learn how .then()/.catch() works once and it's the same for all libraries. - Can
by franciscop 7y ago
It's not much more clear, but it is a standard, which has many advantages:
- Learn how .then()/.catch() works once and it's the same for all libraries.
- Can test against a common API.
- Can combine operations easily like with Promise.all(), which was very difficult with callbacks.
- Chaining is much better since you can return a promise within a promise, which allows for conditional promises.
- No nesting/right shifting, keeping the structure flatter.
- matt-attack 7y agoasync/await has all of those same advantages plus more I believe (and I should add I agree with all of them).
- franciscop 7y agoAsync/await is syntax sugar on top of .then(); without the standardization of promises with .then(), async/await would have been A LOT harder to get cross projects. Ofc async/await is waaay better than .then(), but you were talking about async/await vs callbacks, and so my points :)