3 ms·
If JS had that pattern for hiding `this` and facilitating late-binding like that would it have still needed the `class` keyword?
by imbnwa 3y ago
If JS had that pattern for hiding `this` and facilitating late-binding like that would it have still needed the `class` keyword?
- jahewson 3y ago‘class’ also prevents the constructor from returning a different class/object.
- olliej 3y agoThe class keyword was added (as a functional syntax I mean) specifically because people understand class base inheritance but not prototype inheritance. It is literally just syntactic sugar on what you could do previously, so it’s not “needed” any more than many other basic syntax options. Not sure what you’re specifically talking about wrt to late bind or how you feel it’s relevant to this, so I am curious what you mean. But the reason the class syntax was added to the language was 100% just a programmer familiarity change, nothing else.