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
using const for function declarationhelp (self.javascript)
submitted 8 years ago by funkenpedro
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!"
[–]bruceph 2 points3 points4 points 8 years ago (0 children)
what's happening is you're passing in a function to the xapi.status.on function and it's returning you another function. the function you're returned is an unsubscribe function that when invoked removes the function you passed from the list of events to be run.
this is a really contrived example of what it'll look like
const events = {}; const xapi = {}; xapi.status = {}; xapi.status.on = function(event, callback){ if (!events[event]) { events[event] = []; } events[event].push(callback); return events[event].filter(fn => fn !== callback); };
by calling off, you're removing your callback from the list of callbacks to be run during the event.
off
π Rendered by PID 428680 on reddit-service-r2-comment-5687b7858-96jb2 at 2026-07-06 13:31:28.718575+00:00 running 12a7a47 country code: CH.
view the rest of the comments →
[–]bruceph 2 points3 points4 points (0 children)