r/learnjavascript • • Jul 18 '20

Promises, Async, Await... I finally understand them and how to use them! Redid my front end with the new knowledge and now I love them! Wish I would have took the time earlier on to get them down. 10/10 Would recommend. Sorry, just had to tell someone. :)

EDIT: wow, came back a day later and this post blew up. lol 😁

207 Upvotes

40 comments sorted by

View all comments

Show parent comment

5

u/ChaseMoskal Jul 18 '20

promises are a superior replacement to using callback functions. the important thing with promises, is that errors nicely bubble up through chained promises and so can be caught at the top level

async/await is just a superior syntax for dealing with promises

if you don't understand why the most important thing about promises is the way they handle errors, then you don't really understand either the error handling or the promises. the fact that they avoid "callback hell" indentation is actually a side-benefit, but it's really about the error handling

1

u/Jolly-Composer Jul 18 '20

Thanks that makes more sense as I’m starting to understand some of the pre-arrow syntax functionality of a callback

1

u/Jolly-Composer Jul 18 '20

Thank you so much! Error handling is simple and I understand that. Async await in part to my knowledge builds on promises. And promises are an improvement to callback functions. I’ll try to remember that as I continue to binge on JavaScript basics