Here's what you need:
function mainfunc (){
window[Array.prototype.shift.call(arguments)].apply(null, arguments);
}
The first argument is used as the function name and all of the remaining ones are used as arguments to the called function...
We're able to use the shift
method to return and then delete the first value from the arguments array. Note that we've called it from the Array prototype since, strictly speaking, 'arguments' is not a real array and so doesn't inherit the shift
method like a regular array would.
You can also call the shift method like this:
[].shift.call(arguments);