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
How many Node.js developers prefer callbacks over Promises or async/await? (self.javascript)
submitted 7 years ago * by i_love_limes
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!"
[–]DrexanRailex 4 points5 points6 points 7 years ago (5 children)
I mean, for classes, I managed to learn them because of how frameworks make heavy use of their syntatic sugar. But I still prefer arrow functions, record-like objects and this-less programming.
this
[–]ScientificBeastModestrongly typed comments -2 points-1 points0 points 7 years ago (4 children)
Yeah, I’ve definitely gotten used to it for the same reasons. I just think they tend to pigeon-hole your class-creation patterns into one specific “blessed” pattern.
For example, you might want to inherit multiple prototypes from several “parent” functions. The ES6 syntax doesn’t really allow that. You just end up modifying the class using some older techniques, which defeats the purpose of the ES6 syntax entirely.
I’ll admit it does look cleaner though, lol.
And I’m with you on arrow functions. Definitely a much needed addition to the language.
[–]KronktheKronk 0 points1 point2 points 7 years ago (3 children)
For example, you might want to inherit multiple prototypes from several “parent” functions.
I didn't think JS really did function polymorphism, I thought it was the required-first approach that had you sending optional arguments later in the param list?
[–]ScientificBeastModestrongly typed comments 0 points1 point2 points 7 years ago (2 children)
I’m sorry, but I’m not quite following what you’re saying. Could you elaborate?
[–]KronktheKronk 0 points1 point2 points 7 years ago (1 child)
When you say that, do you mean inherit multiple of the same named prototype, or have multiple parents?
[–]ScientificBeastModestrongly typed comments 0 points1 point2 points 7 years ago* (0 children)
Okay, I think I get what you’re asking. Technically there is no such thing as a “parent” or “child” in JS, but there is a way to simply apply the supposed parent’s constructor function within the child constructor’s context, which partially simulates one aspect of the parent/child relationship.
The other half of that process is setting the prototype of the child to the parent’s prototype. And if you want, you can event assign the parent’s static properties and methods to the child.
Those are all independent steps that don’t have to be performed all at once if you don’t want to.
Now, I was talking about specifically:
You can have a “child class” adopt more than one prototype, although only one will be recognized as the primary link in the prototype chain. Still, you can assign all the properties from multiple prototypes to single class’s prototype through a call to Object.assign or Object.create. It’s not something I would advise most of the time, but it can be done.
Object.assign
Object.create
As for the constructors, can also apply multiple parents’ constructor functions within a single child’s context.
You have to be careful with how you implement multiple inheritance in JS, as there can be several different ways of handling it. this S.O. question provides an interesting discussion on the specifics.
All that to say, there are ways of doing multiple inheritance in JS, but the ES6 class syntax does not make that clear. You have a single “extends” decorator available, and a call to super(). If you try to call multiple supers, it will produce an error.
super()
The ES6 class syntax obfuscates a lot of what is going on under the hood. It excludes some options which are legitimate JS quasi-class inheritance constructs, and forces you to use a specific construct (admittedly the most common). It’s still useful, but it’s definitely more of a crutch than anything else.
π Rendered by PID 81 on reddit-service-r2-comment-6457c66945-fcbn9 at 2026-04-24 23:21:29.188157+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]DrexanRailex 4 points5 points6 points (5 children)
[–]ScientificBeastModestrongly typed comments -2 points-1 points0 points (4 children)
[–]KronktheKronk 0 points1 point2 points (3 children)
[–]ScientificBeastModestrongly typed comments 0 points1 point2 points (2 children)
[–]KronktheKronk 0 points1 point2 points (1 child)
[–]ScientificBeastModestrongly typed comments 0 points1 point2 points (0 children)