I can't seem to dynamically call the private method add from a public function. It seems that this only accesses the public scope which is why I'm not able to call add. Is there a way to do this?
function test()
{
var actionCollection = [];
function add( int1, int2 )
{
return int1 + int2;
}
this.callFunc = function( testMethodFunction, methodArguments )
{
this[testMethodFunction].apply(null, methodArguments);//Method 'add' not found.
}
}
var t = new test();
alert( t.callFunc( 'add', [1,2] ) );
Plus I'm not exactly sure what null is supposed to do considering you can also use this in the apply argument. Could I also have some clarification on what the first argument of apply is supposed to do? Since this is also related to my original question. Thanks in advance for any help!