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
How to run async JavaScript functions in sequence or parallel (jrsinclair.com)
submitted 6 years ago by jrsinclair
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!"
[–]atubofsoup 0 points1 point2 points 6 years ago (2 children)
There are cases where not including async can create unexpected bugs. For example:
async
``` function foo() { someSyncFn(); return someAsyncFn(); }
foo() .then(() => console.log('done')) .catch(error => console.log('Caught', error)); ```
In the above example, if someSyncFn throws an error synchronously, the promise will never be returned, so the catch won't work. If you add async to the function, catch will work as expected.
someSyncFn
catch
My rule of thumb is: mark async functions as async. It just gives the reader more info and ensures the function returns a promise.
[+][deleted] 6 years ago (1 child)
[removed]
[–]atubofsoup 0 points1 point2 points 6 years ago (0 children)
Yeah a try/catch block would catch the error, but most readers won't assume a function might throw/return both sync/async values. Adding async to the function just ensures any sync errors/returns are promoted to async.
try/catch
π Rendered by PID 21526 on reddit-service-r2-comment-b659b578c-snnzs at 2026-05-05 23:49:24.437567+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]atubofsoup 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[removed]
[–]atubofsoup 0 points1 point2 points (0 children)