Okay see the following code:
function person(name){
this.name = name;
this.say = function(){
alert(this.name);
}
};
Main = {};
Main.person1 = new person("p1");
Main.person2 = new person("p2");
Main.person3 = new person("p3");
executeSay = function(argument1){
//Implementation
}
What executeSay
should do is, call the say method of the given argument, I am not sure how it goes but let me put this way executeSay("person1")
should execute Main.person1.say()
and so on. I think we can accomplish this by call
method but I am not sure about the implementation.
Please don't suggest the following approach
say = function(){
alert(this.name);
}
say.call(Main.person1);