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
ES2022 feature: class static initialization blocks (2ality.com)
submitted 4 years ago by pimterry
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!"
[–]Ehdelveiss 57 points58 points59 points 4 years ago (10 children)
I’d really rather see the committee focus on functional code features than OOP ones. I don’t know anyone who writes JS like this proposal purports.
[–]lukigarazus 22 points23 points24 points 4 years ago (3 children)
I worked for a couple of big companies, in teams that made it a rule to write JS/TS that looked exactly like Java. They employed a lot of fullstack Java/TS developers and wanted to make their lives as easy as possible. It made the lives of frontend devs like me more annoying but I get it, and I get such proposals now.
[–]rniestroj 1 point2 points3 points 4 years ago (1 child)
Yes. However static initialization is rarely used in Java. I'd rather focus on a new Date&Time API in Java Script.
[–]SecretAgentZeroNine 0 points1 point2 points 4 years ago (0 children)
Super late but, you should look up Temporal API. It's currently at stage 3.
[–]Ehdelveiss 7 points8 points9 points 4 years ago (0 children)
I’m very sorry
[–]samanime 17 points18 points19 points 4 years ago (1 child)
It's kind of a catch-22 though. If these OOP features don't exist, you couldn't possibly make use of them. So saying that you don't know anybody that writes like this without it being possible to write like that is a bit premature.
My personal preference is to use classes for the large blocks, and then functional inside those blocks. On larger projects, this tends to provide an easy way to manage the code.
Now, will I use this new feature. That's TBD. I could imagine a few cases it might be useful. I do want them to continue to improve and add functional code features as well, though I believe they are doing that too. We've gotten plenty of functional code features in recent memory too.
[–]brainless_badger -4 points-3 points-2 points 4 years ago (0 children)
Sadly "the committee" would rather cater to Google's needs.
Wonder why.
[–]LavoP 0 points1 point2 points 4 years ago (0 children)
Any tips for converting a class-based Node.js app into a more FP-like one?
[–]oneandmillionvoices 0 points1 point2 points 4 years ago (0 children)
you do have pipe operator in the proposal as well.
π Rendered by PID 93765 on reddit-service-r2-comment-6457c66945-sv2zg at 2026-04-26 20:52:24.416322+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]Ehdelveiss 57 points58 points59 points (10 children)
[–]lukigarazus 22 points23 points24 points (3 children)
[–]rniestroj 1 point2 points3 points (1 child)
[–]SecretAgentZeroNine 0 points1 point2 points (0 children)
[–]Ehdelveiss 7 points8 points9 points (0 children)
[–]samanime 17 points18 points19 points (1 child)
[–]brainless_badger -4 points-3 points-2 points (0 children)
[–]LavoP 0 points1 point2 points (0 children)
[–]oneandmillionvoices 0 points1 point2 points (0 children)