I have a function that accepts any number and kind of arguments, so no specific parameter has been defined. This function should call another function passing all arguments.
The problem is that I can pass "arguments" in order to include all arguments but in this case it will work like a single argument and not the way we expect arguments to work.
An example:
The main function:
function handleCall() {
// let's call a sub-function
// and pass all arguments (my question is how this is handled the right way)
function callSubFunction( arguments );
}
function callSubfunction( userid, customerid, param) {
// passed arguments are now
alert( 'userid = ' + userid );
// this will not work, you have to use arguments[2]
alert( param );
}
The example call:
handleCall( 1029, 232, 'param01' );
Using the approach above, all arguments will be stored in "userid" as pseudo-array and items can be accessed e.g. arguments[2] but not using the parameter name "param".
In ColdFusion, the solution for such stuff is the parameter "argumentCollection", this way you can pass parameters stored in a structure without being converted to a single argument with the type struct containing all key/values.
How can I achieve the same with JavaScript?