Passing an array as a function parameter in JavaScript

Posted by Robert on Stack Overflow See other posts from Stack Overflow or by Robert
Published on 2010-05-18T09:42:00Z Indexed on 2010/05/18 9:50 UTC
Read the original article Hit count: 189

Filed under:
|
|
|

Hi all,

i'd like to call a function using an array as a parameters:

var x = [ 'p0', 'p1', 'p2' ];
call_me ( x[0], x[1], x[2] ); // i don't like it

function call_me (param0, param1, param2 ) {
    // ...
}

Is there a better way of passing the contents of x into call_me()?

Ps. I can't change the signature of call_me(), nor the way x is defined.

Thanks in advance

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about array