I want to enter code in javascript for debugging purposes inside each prototype of my methods in javascript. This example shows only one class, but suppose I have hundreds of classes, and each class has dozens of methods . This mechanism should be performed at the prototype level without the need to indicate the name of each class / method.
function MyClass1() { this.attrib = "ABC"; } MyClass1.prototype.myMethod = function() { alert("first row");
The idea is to dynamically inject some code before the first line of myMethod () during the first load / execution of javascript code. For instance:
MyClass1.prototype.myMethod = function() { alert("I was injected dynamically"); alert("first row"); }
So, for every other class and method, this should happen. Is this possible with the Function.prototype approach?
source share