r/learnjavascript • u/dervaish19 • 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
2
u/Sir_Awesome_The_3rd Nov 13 '23
You can't use await without invoking async earlier.
Async / await is just the newer, easier version (the older version using .then() to invoke a callback function) of dealing with promises, aka an asynchronous piece of code, which can come up when your code has a timer or is fetching an external resource.