|
|
|
|
|
by Kwantuum
971 days ago
|
|
There are several points in the article which are just plain wrong: - no private properties (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...) - no readonly properties: You can use a getter. Or define the property as non-writable, the syntax isn't nice but in my opinion it's still much nicer than what the article proposes. Some of the points are just a matter of taste ("this" is awkward) There's the implementation itself which forces you to use non-idiomatic code for no good reason or benefit (Class.init instead of new, just why? You can absolutely return a constructor function there while preserving everything else) Doing what the article proposes also destroys the ability to do instanceof checks because the prototype of instances is not set (can be fixed), and inheritance is severely limited if you want to preserve any of the purported benefits. You might say that inheritance is actually not a good thing and so it's a feature, not a bug, but if that's your opinion why are you trying to mimic a class? |
|