How do I write a Javascript function that accepts a variable number of parameters, and forwards all of those parameters to other anonymous functions?
For example, consider the scenario of a method that fires an event:
function fireStartedEvent(a,b,c,d,e,f,g,...) {
for(var i = 0; i < startedListeners.length; i++) {
startedListeners[i](a,b,c,d,e,f,g,...);
}
}
Especially since I have an event factory that generates these fire methods, these methods have no interest in knowing how many parameters a given event or its handlers consume. So I have it hard-wired at 7 right now (a through g). If it's any less, no problem. If it's any more, they get cut off. How can I just capture and pass on all parameters?
Thanks.
(Using jQuery or any other Javascript framework is not an option here.)