I have this object
var X = {
a:function(args){
},
b:function(args){
},
c: ...... etc
}
X.a() // will do somthing
I want to modify the method that it will do one more statement say “counter++”
So
var oldX = X.a();
X.a =function(args){
oldX(args);
counter++;
}
if i want to make this change to all the methods of the object X . So how can i do this by looping through the object like?
for(var i in X){
}
when i tried it by storing in an ooldArray of methods but while executing it will replace all the method with lastone ..
I’m completely sure the behavior you want should be achieved using prototypical inheritance. But I’m know nothing about your architecture and requirements, so here is the solution written in the way you want: