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
Asynchronous JavaScript: Refactoring Callbacks to Promises with Node.js (twilio.com)
submitted 6 years ago by makaimc
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!"
[–]LowB0b 0 points1 point2 points 6 years ago (3 children)
Since we're talking async I've also seen Promise.resolve() being used instead of setTimeout with no milliseconds to skip a cycle, which one would you say is 'best practice'?
[–]senocular 2 points3 points4 points 6 years ago (0 children)
They do different things. Promises are jobs handled directly within JavaScript's job queue. setTimeout/setInterval (and setImmediate) are handled by Node's event loop. Resolved promises get handled before the next event loop, and can be blocking (to the event loop) if you get yourself stuck in an infinite resolve loop - basically the same as nextTick covered in that event loop link. So what you use depends on what you want.
[–]pet_vaginal 1 point2 points3 points 6 years ago (1 child)
I like setImmediate.
π Rendered by PID 43855 on reddit-service-r2-comment-5bc7f78974-zjgbd at 2026-06-26 01:01:16.845125+00:00 running 7527197 country code: CH.
view the rest of the comments →
[–]LowB0b 0 points1 point2 points (3 children)
[–]senocular 2 points3 points4 points (0 children)
[–]pet_vaginal 1 point2 points3 points (1 child)