3 ms·
The point the OP was making that the class keyword was a mistake, not that inheritance was a mistake. This is an entirely different topic. Furthermore, Javascr
by camus2 10y ago
The point the OP was making that the class keyword was a mistake, not that inheritance was a mistake. This is an entirely different topic.
Furthermore, Javascript classes make writing mixins AKA composition a breeze, compared to before:
http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/ http://justinfagnani.com/2015/12/21/real-mixins-with-javascr...
This link is an excellent rebuttal to Eric Elliot article and how he achieve composition through copying by the way.
So even if you like composition over inheritance, Javascript classes still allow you to write safer and clearer and cleaner code. Now you can do away with ugly factories and property copying.
> Object.assign is far less fragile than inheritance
You realize the using Object.assign means copying properties from object to object over and over and increase memory requirements in order to run a script.
So my point still stands, there is not a single disadvantage introduced with the class keyword.
- tchaffee 10y agoThanks for the article, it's a long read that requires some thinking so I'll get to it tomorrow. In the meantime I'll put a Kyle Simpson chapter out there as a rebuttal to "there is not a single disadvantage introduced with the class keyword". He makes a good case that there is more than one disadvantage to the class keyword. https://github.com/getify/You-Dont-Know-JS/blob/master/this%20%26%20object%20prototypes/apA.md https://github.com/getify/You-Dont-Know-JS/blob/master/this%...