3 ms·
What are some other examples of the class keyword ruining Javascript?
by ihuman 8y ago
What are some other examples of the class keyword ruining Javascript?
- mkozlows 8y agoDecorators, which have to be added as a language concept because of classes, when otherwise higher-order functions would do what needs to be done.
- dmitriid 8y agoIt’s a non-fitting abstraction that’s poorly glued on top of a prototype-based language. As a result, uou have thongs like: - methods have no access to `this` on the instance of the class. Because they are defined on the prototype. As a result, you have to manually do a .bind(this) in your constructor for every method that needs access to `this` - meanwhile, if you define a class field: `field = () => this.foo` (with an arrow function), then you have no problems accessing the instance. Because of different scoping rules, binding etc. - and now there’s private fields. Which are just a hack to make them sorta kinda work