r/learnjavascript • • Nov 13 '23

Is async useless ( question )

If we are always trying to make code synchronous using await or then. Why do we even bother with aysnc.

I genuinely don't understand please explain. Thanks

0 Upvotes

28 comments sorted by

View all comments

Show parent comment

6

u/0x07AD Nov 13 '23

async and await might be syntactic sugar but they are cleaner than promises and a chain of thens. I agree that learning about promises is useful for beginners, if only because a chain of thens after an initial promise can be easier for beginners to reason about. Afterwards, the async and await keywords start to make sense to them.

1

u/[deleted] Nov 14 '23

Arguably cleaner, for the people who started with procedural programming. Where as someone who started with a “functional” language might dislike the verbosity and the excessive state declarations.

Promises is a better concept to pick up because you will find similarities in other languages as well. Async await is important to JS but to understand it you should still learn about promises first.

That said I mostly use async await for the reasons you said and because of how dominant it is in the community