About the implementation of class features...
Does anyone know when we will get a decent way to create public, private and protected class members ? I come from c++ and js way to do those irks me.
I can't fathom the reason behind the half-assed implementation... Did they want to taunt and torture the oop people ? /rant
Posted Dec 15, 2016, 3:49 AM UTC
The design motto for ES6 classes was “maximally minimal”, for two reasons: To ensure no mistakes were made. And to get consensus in favor of this feature.
For now, I either use symbols as keys for private properties. Or I prefix property names with underscores (relying purely on a naming convention without actually protecting them in any way).
Improvements take time, a proposal for private fields is in the works: https://github.com/tc39/proposal-private-fields
I've been using var declaration and getter/setter in the constructor. I've have a class that have a custom creator that automatically make the variable with the visibility required in the constructor. All you have to do is inherit from it and send the var in the proper format to the super().
I had to figure how to do multiple inheritance with Class too that was fun, :X.
[edit] why do they need their funky symbols. the keyword private is the obvious choice there, why an unclear #...
There's an FAQ which is mostly about exactly that question.
You're a funny one. A lot of language manage to do great without it. Js syntax can become shit very quickly, and not even talking about the jQuery...
Other languages do not have JavaScript's object model.