Usually the easiest and proper way to do so is with the prototype as all changes to the Object prototype object are seen by all objects through prototype chaining.
newB().handleClick();// Uncaught TypeError: (intermediate value).handleClick is not a functionnewB().handleLongClick();// A.handleLongClick// B.handleLongClick
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Apart from recreation of the function itself it has other drawbacks too.
Let me give you two examples, first let's say you have a class with an arrow function and when testing you want to mock it:
Usually the easiest and proper way to do so is with the prototype as all changes to the
Object
prototype object are seen by all objects through prototype chaining.But in this instance:
A.prototype.handleLongClick
is defined.A.prototype.handleClick
is not a function.Same happens with inheritance:
Then: