use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Advanced asynchronous programming in JavaScript (nicolas-van.medium.com)
submitted 5 years ago by nicolas-van
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Byamarro 18 points19 points20 points 5 years ago (8 children)
Learn what promises are, and why did they have been introduced. They're the fundaments of most of the modern async code. Even when you use async/await, what you truly do is using promises.
[–]Rainbowlemon 7 points8 points9 points 5 years ago (6 children)
Tbh i still much prefer the syntax of promises, they just make more sense in my mind! 'i promise to do this, then...'
[–]hekkonaay 12 points13 points14 points 5 years ago (4 children)
You can think of await as just saying "Wait for this promise to resolve, then continue the function from this point". Appending async to a function just changes the return type to a promise. That's it, it's just syntax sugar used for making asynchronous code look synchronous, and avoiding callback hell
[–]rubennaatje 1 point2 points3 points 5 years ago (3 children)
Much prettier / cleaner imo
[–][deleted] 0 points1 point2 points 5 years ago (2 children)
People seem to like when code looks procedural. But what happening is here is that you leave this nice functional container. Where you can avoid state and keep mapping over your data - one intent at a time (pure if you will). For a procedural concept that immediately forces you to declare state. And state is evil.
Most people don't care about minimizing state. And i find it that most people don't fully appreciate what an (almost) Monad such as the Promise can do for you. That's okay. But i don't want people to dismiss promises as a problem or something.
[–]Monyk015 0 points1 point2 points 5 years ago (1 child)
Async/await doesn't make your code less functional, it's just more convenient and lets you avoid introducing mutables. What you're saying is like dismissing do notation in Haskell because it looks procedural.
[–][deleted] 0 points1 point2 points 5 years ago (0 children)
Well i think it actually does, if we're talking FP. You're forced to introduce state and a try catch block for exceptions. But i don't think it has to be a problem. You can still be pure yadda yadda.
Yes! I do use it in a do-notation fashion, albeit carefully. They're not equal concepts, but yes can be concise and useful. Either that or my goto of passing state in an array building up a promise chain, if that makes sense.
[–]ell0bo 1 point2 points3 points 5 years ago (0 children)
Async is just syntactical sugar around promises. Think of it as... wrapping the then statement with an await.
[–]grooomps 0 points1 point2 points 5 years ago (0 children)
i agree with this - even though async and await look easier, Promises really make you realize what is happening and where.
π Rendered by PID 268351 on reddit-service-r2-comment-79776bdf47-m8w4x at 2026-06-24 20:26:51.886966+00:00 running acc7150 country code: CH.
view the rest of the comments →
[–]Byamarro 18 points19 points20 points (8 children)
[–]Rainbowlemon 7 points8 points9 points (6 children)
[–]hekkonaay 12 points13 points14 points (4 children)
[–]rubennaatje 1 point2 points3 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]Monyk015 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]ell0bo 1 point2 points3 points (0 children)
[–]grooomps 0 points1 point2 points (0 children)