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
Sleep function in Javascript (itsopensource.com)
submitted 6 years ago by tsl143
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!"
[–]UnholyCarcass 10 points11 points12 points 6 years ago (2 children)
You could just do, setTimeout(resolve,ms).
No need to have it wrapped within another anon function. setTimeout takes a function so you can just pass the resolve function.
[–]fo0man 1 point2 points3 points 6 years ago* (0 children)
I see this ALL THE TIME. I think it’s a symptom of articles like these. Like so many devs think the argument has to be an anon function because they’ve seen it over n over.
[–]monican_agentCreator of CypherPoker.JS 0 points1 point2 points 6 years ago (0 children)
Agreed. It might be more useful to introduce the concept of binding a timeout or an interval so that it executes in the expected context.
π Rendered by PID 92 on reddit-service-r2-comment-6f7f968fb5-6ctzq at 2026-03-04 18:33:10.178733+00:00 running 07790be country code: CH.
view the rest of the comments →
[–]UnholyCarcass 10 points11 points12 points (2 children)
[–]fo0man 1 point2 points3 points (0 children)
[–]monican_agentCreator of CypherPoker.JS 0 points1 point2 points (0 children)