Is there a way to forward an ‘arguments’ object to another method?
Currently, if you try to use an arguments object as a passed parameter, it gets wrapped up in another arguments object.
The only workaround I can currently think of is to do something like:
switch(arguments.length)
{
case 1: globals[methodName](arguments[0]);break;
case 2: globals[methodName](arguments[0],arguments[1]);break;
etc....
}
Any ideas?
greg.
Javascript supports the .apply() function, but this is currently not functioning properly in the JavaScript engine Servoy uses.
But, the good news is that it is in Servoy 4.0!
It allows you to apply the Arguments array onto another method.
So, it’s either your option now in 3.5 or you can dynamically build a text string like “globals.myMethod(arguments[0],arguments[1], arguments[2])”, adding the appropriate number of “arguments” based on the length of the arguments array and then eval that text string.
Paul
“apply” will be nice to have. I’ll make due with the switch statement for now.
greg.