|
|
|
|
|
by JSDave
3394 days ago
|
|
There's a lot of reasons against classes in JS.
This list has a lot of articles.
https://github.com/joshburgess/not-awesome-es6-classes
A common point seems to be against the brittleness caused by inheritance (including prototypical) in general.
Personally, I find that the tiny amount of performance you give up by using factory and composition patterns is generally worth not having to deal with binding the right context |
|
This is what's wrong with the JS community and why everything is so hype driven... this list gives the impression that if you want to be a good JS developer you should've even THINK about trying to use classes in your JS because if you do then you don't truly "get" JS.
Think for yourself and decide if classes will improve your code in the way you plan to use it. Classes have hugely improved my company's JavaScript, it works well considering our developers understand OOP much better than they do functional programming, which I think is pretty common.
We don't rely on inheritance, we reuse by composition (which is just as easy to do with class as it is to do with protypes).
Classes are fine! Use them if you want to! Don't use them if your existing code relies heavily on prototypal inheritance, but if you just wanna wrap some methods around some internal state and you like the way the class syntax looks compared to the prototype syntax don't let some think piece on medium try to convince you that classes are bad.
EDIT: sorry to go off on a slightly OT rant on your comment... I just got frustrated by the link you posted.