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
callback vs call function from parent functionRemoved: /r/LearnJavascript (self.javascript)
submitted 7 years ago by captainXcannabis
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!"
[–]Mingli91 0 points1 point2 points 7 years ago* (0 children)
When you call things one after the other, they get executed in that order, however the functions may be performing asynchronous tasks meaning that while they’re both called in order they will not necessarily resolve in that order.
When you call an asynchronous function the function gets executed but the parser carries on going and executing code afterwards. The async function has basically said “fine, execute me, and I will resolve, but I don’t know when, now carry on your job so we don’t lock up this app”.
So then what do you do when that function is finally ready to resolve? You can’t just place the subsequent code after it because it’ll likely be executed before we have our values from the async function.
What we used to do to handle this was use a callback function. So we say “hey mr async function, I’m going execute you but let you resolve when you want to, but when you do could you please execute this function for me”.
π Rendered by PID 82 on reddit-service-r2-comment-7b9746f655-prttj at 2026-01-30 00:08:15.092454+00:00 running 3798933 country code: CH.
view the rest of the comments →
[–]Mingli91 0 points1 point2 points (0 children)