How to send array to function as multiple arguments?

Viewed 13275

In Javascript I have simple test code:

function x(a, b) {
  alert(a);
  alert(b);
}

var c = [1,2];
x(c);

which send an argument c to function x() as one argument, assigned to a and b stays undefined :-/

How can I send an array as multiple arguments to a function, not as one array?

2 Answers
Related