function with array parameter javascript code example
Example 1: js array as parameter
function myFunction(a, b, c) {
console.log("a: " + a);
console.log("b: " + b);
console.log("c: " + c);
}
var myArray = [1, -3, "Hello"];
myFunction.apply(this, myArray);
Example 2: javascript function with array parameter
const args = ['test0','test1','test2'];
function call_me(param1, param2, param3){
}
call_me.apply(this, args);
Example 3: make a parameter array in js
var x = [ 'p0', 'p1', 'p2' ];
call_me(x);
function call_me(params) {
for (i=0; i<params.length; i++) {
alert(params[i])
}
}