I have a CSV file of some data and for each line, I split it by the comma to get an array vals.
Now I want to pass vals into a function, but "flatten" it (without changing the function because it is used elsewhere)
function foo(x, y, z) {
return x*y*z:
}
var vals = [1, 3, 4];
//want a shortcut to this (this would be a nightmare with like 20 values)
foo(vals[0], vals[1], vals[2]);
Edit:
Sorry, kind of left out a big detail. I only want part of the array, like the first 10 elements of a 12 element array. Any shortcut for this?
varfor the arguments.function foo(x, y, z)works fine.