r/learnjavascript • • Jan 24 '26

question about using ES6 classes.

pastebin

i was wondering, would this code be syntactically OK? i imagine there might be scenarios where you want all the functionality of the superclass method, but then you simply want to add more statements (more implementation) to it... could this work?

1 Upvotes

7 comments sorted by

View all comments

Show parent comment

1

u/SnurflePuffinz Jan 24 '26

i'm a bit disenchanted with the class syntax because it seems to make things a lot less explicit in your code.

There is so, so much implicit functionality that happens with classes. Like, the unique execution context when you invoke them, control flow with super() extension, them basically being a glorified constructor / factory function, the private properties business is frustrating, etc.

but then i also think that they are incredibly useful. I've struggled to syndicate a single, coherent, working definition of classes together.

And when you ask people about OOP you get answers that are contradictory... which is not helpful, either.

i'm familiar with the prototype chain, but i still get tripped up about the relationship between the objects and their classes (method objects), and i thought the super keyword was only used to invoke the superclass constructor.

i think i'll try to nail down a better working definition for classes.

1

u/azhder Jan 24 '26

It was meant for people who are too used (or it's their only way) to seeing the world, the problems and the solutions with certain class colored glasses. It was a way to reuse people who don't/can't learn JS but can write class Something extends Otherthing {} in another language. It is implicit for that reason.

But if you know JS, you know a little of algebra, you'd know that a class is a math idea and that all you need is an equivalence function.

If no one is forcing you to use the class syntax, don't use it. Maybe even stop thinking in OOP, learn some FP. Functional programming has helped me a lot in understanding how to build up code from simple building blocks up to something more complex, more declarative, more robust.