append a method to an already existing class in javascript

Solutions on MaxInterview for append a method to an already existing class in javascript by the best coders in the world

showing results for - "append a method to an already existing class in javascript"
Sophia
21 Nov 2019
1Array.prototype.newMethod = function() {}
2/* - Replace "Array" with your Class name - 
3
4 Typing the name of your Class in the console
5 won't show the newly added method.
6Only by appending .prototype to the class name
7you will see the new method appended to the class, in its definition.
8
9The technique is also called Monkey Patching and is
10NOT recommended, for the reasons outlined in the source link*/