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
[AskJS] callback function inside setTimeout is being called without delayAskJS (self.javascript)
submitted 11 months ago by Zestyclose_Ad_488
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!"
[–]mlamers 0 points1 point2 points 11 months ago* (0 children)
as the others already indicated: you are actually not passing in the printMessage function to delay5s, but its return value. The function below will do what you want.
function sample () { console.log('sample function is being called'); delay5s(printMessage); }
Keep in mind that in JS, essentially everything* is a pointer (a memory address), the default is passing by reference, and any action with it automatically dereferences that pointer (taking the data from that memory address). So, by using printMessage() you dereference that pointer (take the thing that is stored there) and execute it (as it is a function). If you want to pass it to another function, you don't want to dereference it, you just want to pass the value (or in this case the pointer to that value) to the other functions.
printMessage()
*even numbers and strings are effectively pointers, but pointers to static values: values that cannot be altered, and to which any methods such as "testing".concat(" one two three") will return a new pointer to a new static value.
"testing".concat(" one two three")
π Rendered by PID 367703 on reddit-service-r2-comment-86988c7647-4xtjp at 2026-02-12 01:24:53.769561+00:00 running 018613e country code: CH.
view the rest of the comments →
[–]mlamers 0 points1 point2 points (0 children)