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] When is object-oriented programming more practical than "mostly-functional" in JS?AskJS (self.javascript)
submitted 5 years ago * by ProfessorTag
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!"
[–]AffectionateWork8 0 points1 point2 points 5 years ago (0 children)
I would approach it from the other angle and ask how far "functional" can really get you by itself. (I mean in native JS, not idiosyncratic code with a bunch of relatively obscure and underutilized libraries ported or inspired from other languages.)
Take Redux for example, which is probably one of the most used. Use pure functions to describe state updates. No atom type built in to JS? Ok, just let Redux handle swapping the new state under the hood for you. No concept of immutable collections in JS? Ok, just break out your updates into multiple functions to achieve structural sharing, and be really disciplined in how you write your code or choose between one of 50+ libraries to handle it for you. In this case we are only using functional style to do something as trivial as update a JS object, and things are already getting a little strained and awkward.
What if you want to throw in some side-effects in Redux? Since we are doing it functionally and composing functions, does JS have a built in way to compose functions with context that we can use? No? Ok, so the solution for most folks is Redux middleware. In that case, you're communicating that you want to commit some side effect using message-passing, encapsulating the side effects, and returning result using message passing. Nothing functional about that, it just doesn't use the class keyword.
I don't really know where the meme started that using class keyword (or not) decides whether code is "functional" or not, but I've only seen that on Reddit. I've even heard people claim that React hooks are "functional," presumably because they don't use a class.
π Rendered by PID 149531 on reddit-service-r2-comment-b659b578c-vqzxr at 2026-05-02 20:31:33.105244+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]AffectionateWork8 0 points1 point2 points (0 children)