3 ms·
The semantics of JS classes are still different in enough subtle ways: constructors and constructor subclassing, (lack of) object properties, hoisting, etc. Tha
by jallmann 11y ago
The semantics of JS classes are still different in enough subtle ways: constructors and constructor subclassing, (lack of) object properties, hoisting, etc. That is on top of the new keywords, new function syntax, etc. All that needs to be mapped onto the model of "classical" Javascript in order to completely understand the language. There are enough gotchas there to disqualify JS classes from being simply sugar.
- Touche 11y agoYou can add object properties to a ES6 class's prototype, no? EDIT: Just tested in Firefox and indeed you can.
- jallmann 11y agoNot in the class declaration, though. Why force the programmer to go through the prototype, when ES6 provides such a "convenient" abstraction around it?
- phpnode 11y agoComing to the spec soonish and already supported in Babel - https://github.com/jeffmo/es-class-fields-and-static-properties https://github.com/jeffmo/es-class-fields-and-static-propert...