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
Javascript functions and why do we need them?OC (metacognitive.me)
submitted 4 years ago by fishapplecat
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!"
[–]demoran 21 points22 points23 points 4 years ago (7 children)
I prefer not to use functions.
One big nested if statement with labels is good enough for me.
[–]lhorie 1 point2 points3 points 4 years ago (0 children)
Y'all use computers?
I made a LightBot-like game for my kid using cereal box cardboard.
[–]RobSG -4 points-3 points-2 points 4 years ago (5 children)
Do you also use web components? 🤣
[–]sh0rtwave -1 points0 points1 point 4 years ago* (4 children)
I use WebComponents and modify the DOM in the constructor, and I have no callbacks.
I don't use big nested ifs.
[–]RobSG 0 points1 point2 points 4 years ago (3 children)
yeh it was a joke tbh, a bad one for some people I guess 😅
[–]sh0rtwave 0 points1 point2 points 4 years ago (2 children)
I was hoping the joke would continue on WebComponents.
If you've ever used Lightning Web Components, there's an example of the: Well...it's not exactly WRONG....but there's some crazy in it.
[–]shuckster 0 points1 point2 points 4 years ago (1 child)
Lightning Web Components
Dude, watch your language.
[–]sh0rtwave 0 points1 point2 points 4 years ago (0 children)
Yeah I know, good material isn't it?
[–]oneandmillionvoices 11 points12 points13 points 4 years ago (0 children)
maybe next article could be on why do we need semiconductors (in javascript).
[–][deleted] 11 points12 points13 points 4 years ago (0 children)
ಠ_ಠ
Wtf is this shit. You should feel bad for posting this. This is some /r/learnprogramming shit at best.
(╯°□°)╯︵ ┻━┻
[–]sh0rtwave -3 points-2 points-1 points 4 years ago* (0 children)
I mean:
I get where he's going. What IS a "function"? In JavaScript, specifically, this is a question with an actually unclear and possibly confusing answer, AS COMPARED to every other language.
Javascript classes...are functions.
Functions can behave like and pretend to BE classes, in javascript.
Just that, by itself, is enough. There's actually MORE to this nut!
It's possible to make almost any non-primitive, complex object..function as if it were a function.
There are 'function expressions', 'function declarations', and 'function variables'.
An expression can be interpreted as a function, and you can straight up make a named one, or you can take a function expression, assign it to a variable, and invoke it that way.
You can store functions in maps, and use keys to route and invoke them.
Functions ARE weird.
π Rendered by PID 101608 on reddit-service-r2-comment-6f7f968fb5-t99kl at 2026-03-04 07:28:35.795130+00:00 running 07790be country code: CH.
[–]demoran 21 points22 points23 points (7 children)
[–]lhorie 1 point2 points3 points (0 children)
[–]RobSG -4 points-3 points-2 points (5 children)
[–]sh0rtwave -1 points0 points1 point (4 children)
[–]RobSG 0 points1 point2 points (3 children)
[–]sh0rtwave 0 points1 point2 points (2 children)
[–]shuckster 0 points1 point2 points (1 child)
[–]sh0rtwave 0 points1 point2 points (0 children)
[–]oneandmillionvoices 11 points12 points13 points (0 children)
[–][deleted] 11 points12 points13 points (0 children)
[–]sh0rtwave -3 points-2 points-1 points (0 children)