[thelist] JavaScript: Passing arguments from one function to another

liorean liorean at gmail.com
Sat Apr 28 07:38:43 CDT 2007

On 28/04/07, Joe Ngo <chilijoe at gmail.com> wrote:
> I'm trying to write a function that calls another function. I'd like this
> function to pass all arguments it received to another function such that the
> result is
> that the call to the other function has the same parameter signature.
> Something similar to the following, except that myFunction doesn't know how
> many parameters the other function have:
> function myFunction() {
>   if (some_condition) otherFunction(arguments[0],
> arguments[1], arguments[2], ...);
> }

Function.prototype.apply should do the job:

function myFunction(){
David "liorean" Andersson

More information about the thelist mailing list