Hacker News new | past | comments | ask | show | jobs | submit login

People already use it as though it had classes, so it makes sense to add the sugar. It will prevent errors such as SomeObject.prototype.foo = {} by not allowing data on the class body.



Some people already use it as though it had classes.

I don't like those people.


It has objects which you can use as prototypes and create instances of those objects using the new keyword. Doing this has the side effect of my better performance. With all of that being the case, what do you expect people to do? The good thing about maximally minimal classes is that it prevents people from making mistakes by assuming that prototypes work just like classes in java/etc.


In my experience (and some benchmarking), there's no real difference in speed between using a Module-based factory method or using object prototypes. Modern JS engines optimize for both.


Well it's not very good at not having classes either, due to the constructor mess (and `instanceof` being broken if you're doing constructorless JS as far as I know, which is very frustrating — of course it's even more broken if you have cross-frame objects involved) so...




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: