Answers for "append a method to an already existing class in javascript"

0

append a method to an already existing class in javascript

Array.prototype.newMethod = function() {}
/* - Replace "Array" with your Class name - 

 Typing the name of your Class in the console
 won't show the newly added method.
Only by appending .prototype to the class name
you will see the new method appended to the class, in its definition.

The technique is also called Monkey Patching and is
NOT recommended, for the reasons outlined in the source link*/
Posted by: Guest on November-24-2020

Code answers related to "append a method to an already existing class in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language