I've the following situation: I want to prepend (unshift) the arguments given to an function by another parameter. How my current approach looks like:
function eventReferer(event) {
var self = this;
return function() {
var args = ([event]).concat(Array.prototype.slice.call(arguments, 0, arguments.length));
return eventFunction.apply(self, args);
};
}
"eventFunction" is a custom function. I need to redirect the called event + all arguments to this function.
Because "arguments" is no valid Array in Javascript, the method of Array will not work. Is there any better way to merge my event and the arguments to a new array?