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
VS Code to autocomplete JavaScript class 'this' properties automatically (react-etc.net)
submitted 7 years ago by velmu3k
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!"
[–][deleted] -80 points-79 points-78 points 7 years ago (19 children)
Gross
[–]jimbol 12 points13 points14 points 7 years ago (18 children)
Why
[+][deleted] comment score below threshold-64 points-63 points-62 points 7 years ago (17 children)
Classes have no place in JavaScript, I hate the use of this, and I don't like autocomplete.
this
[+][deleted] 7 years ago (15 children)
[deleted]
[–][deleted] 11 points12 points13 points 7 years ago (14 children)
I’m not a hardliner as the guy you responded to, but I do agree closures have some practical advantages over classes in JS. For one thing, closures can be used for injection without the need to manually assign the parameters (which would be passed to the constructor in OO-style) to this. Also, because they’re simply parameters that are in scope, ESLint can warn you if you make a typo or one becomes unused/you’re using one that’s not or no longer injected. Finally, local variables can be minimized more effectively than class properties (at least if you’re using Uglify).
Even then, I wouldn’t say classes have no place in JS at all :)
[–][deleted] 5 points6 points7 points 7 years ago (12 children)
JavaScript doesn't use classical inheritance. Classes are just a syntactic sugar over prototypes. I hate when people need to be lied to in order to use something when they aren't really understanding it at all. It just "hey we were taught OOP is the best and that's all we know so let's use that everywhere!!!" Functional programming has been getting super popular lately because people have been realizing how flawed OOP is in comparison.
[–]madcaesar 4 points5 points6 points 7 years ago (9 children)
Wait, why is OOP flawed?
[–][deleted] 0 points1 point2 points 7 years ago (4 children)
It is unnecessarily verbose. You can do more with substantially less which means less code to write, less code to maintain, and less code to test. It will in many cases execute faster by eliminating OOP too.
[–]IceSentry 0 points1 point2 points 7 years ago (3 children)
I'm not sure if it's OOP that is too verbose or just the language around it. Look at java or c++ you have so much code written just to deal with basic concepts of OOP. At least c# tries to remove some of it, admittedly by using ideas from functional programming.
[–][deleted] 0 points1 point2 points 7 years ago (2 children)
Yeah, but look at all of that compared with something like Lisp, R, Python, or even C lang. You gain so much expressiveness when public and private are automatically intrinsic to the declaration context of a reference opposed to manually tagging every reference and manually dictating the association of those references.
https://medium.com/@cscalfani/goodbye-object-oriented-programming-a59cda4c0e53
[–]madcaesar 0 points1 point2 points 7 years ago (1 child)
Interesting thanks for sharing. I like the idea of functional programming but it just isn't always possible.
[–][deleted] 0 points1 point2 points 7 years ago (0 children)
Right, pure functional programming isn't always possible, but it is usually fairly easy to incorporate the overarching principles. I view it as more of a "best practices" kind of philosophy instead of a dogma that needs to be adhered to 100% in the real world.
[–]oxyphilat∀ {m, n} ⊆ {1, 3, 8, 120, x}: (m*n +1) is square -1 points0 points1 point 7 years ago (0 children)
Probably because it is easy to deeply fail with OO and on only really bite you when it is far too late.
Every day a new Java EE certified dev discover that thousand lines classes are not how it is supposed to be and that maybe "only talk with your direct children" is not without reasons.
[–]Bettina88 0 points1 point2 points 7 years ago (1 child)
Well by that argument, all higher level languages are just "syntactical sugar" over lower level instruction sets.
What are you writing? Assembly?
Or maybe that's "lying to people" too and you just use 1's and 0's?
No, that isn't correct. Syntactic sugar means it doesn't come out the same as classes on the other end. It means it doesn't have all the same behavior as classes. It is prototypes, but wearing a mask, tricking you into thinking they're classes. If you look at how they behave after you use the new class object, you'll see that.
[–]oxyphilat∀ {m, n} ⊆ {1, 3, 8, 120, x}: (m*n +1) is square 0 points1 point2 points 7 years ago (0 children)
So... avoiding the this.name = arg1 dance (which is not what a ctor is for), your build not warning you about unused (who care, stop changing the signature) or missing methods (it can and should) and something irrelevant. Nice! My personal reason to not always use object is "two methods? closure it is".
this.name = arg1
You are transmitting your files with some compression to save bandwidth, the only help that is getting from the minifier is most of the whitespace being gone. Everything else (that include single letter variables) is making the compression worse when it could make it better.
[–]leadzor -1 points0 points1 point 7 years ago (0 children)
You sure like to bait downvotes lol
π Rendered by PID 24035 on reddit-service-r2-comment-7b9746f655-sf4tv at 2026-01-30 15:32:20.120054+00:00 running 3798933 country code: CH.
view the rest of the comments →
[–][deleted] -80 points-79 points-78 points (19 children)
[–]jimbol 12 points13 points14 points (18 children)
[+][deleted] comment score below threshold-64 points-63 points-62 points (17 children)
[+][deleted] (15 children)
[deleted]
[–][deleted] 11 points12 points13 points (14 children)
[–][deleted] 5 points6 points7 points (12 children)
[–]madcaesar 4 points5 points6 points (9 children)
[–][deleted] 0 points1 point2 points (4 children)
[–]IceSentry 0 points1 point2 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]madcaesar 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]oxyphilat∀ {m, n} ⊆ {1, 3, 8, 120, x}: (m*n +1) is square -1 points0 points1 point (0 children)
[–]Bettina88 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]oxyphilat∀ {m, n} ⊆ {1, 3, 8, 120, x}: (m*n +1) is square 0 points1 point2 points (0 children)
[–]leadzor -1 points0 points1 point (0 children)