I have an class called myObject
, which has multiple methods, one of which is add
. I am using another function with an argument for which function of myObject
I want to use. If I want to use add
, I pass it 'add.' If I want to use delete
, I'd pass it 'delete,' etc. In the definition of the function test
, if I use obj.add
it works fine, but if I use obj.func
, the passed parameter, it doesn't work. I tested to make sure func = add
, and it is, but for some reason it won't work with the parameter. Any ideas what I am doing wrong?
testObj = new myObject();
test(testObj, 'add', 3);
function test(obj, func, parm){
var answer = obj.func(parm);
}