Hacker News new | ask | show | jobs
by Can_Not 2997 days ago
Totally agree, checkout this example:

> If you change/replace a method (on purpose or by accident) on the parent "class", the child "class" and/or instances will still be "affected"

I knew when reading this line exactly what the author was about to do to mislead the unsuspecting user. Directly edit the prototype and feign surprise. The prototype is representative of the class itself, basically a default of all properties for that class. The correct (and obvious) way to override a class method for only one member of the class is to assign a new function on the property directly, not into the prototype's version of the property. Class definitions being mutated in an application is extremely uncommon. This is like putting your hand on a hot stovetop and then complaining that you burnt yourself.