0

I need to know if a prototyped class understands a method. For example:

MyClass.prototype.myMethod1 = function() {
    ...
    return "Hello World!";
};

MyClass.prototype.myMethod2 = function() {
    ...
    return "Bye World!";
};

MyClass.prototype.caller = function(functionName){ //This is the method that I need to know
    if (functionName == "myMethod1") return "Exist!, is myMethod1.";
    if (functionName == "myMethod2") return "Exist!, is myMethod2.";
    return "Sorry, it doesn't exists here.";
}

This is just a poor example. I need to identify if the method is not understood for MyClass and, in that case, delegate it.

Thanks!

4

2 に答える 2