How to pass an array to a function argument in js code example

Example 1: js array as parameter

function myFunction(a, b, c) {//number of parameters should match number of items in your array
  	//simple use example
  	console.log("a: " + a);
  	console.log("b: " + b);
  	console.log("c: " + c);
}

var myArray = [1, -3, "Hello"];//define your array
myFunction.apply(this, myArray);//call function

Example 2: javascript function with array parameter

const args = ['test0','test1','test2'];
function call_me(param1, param2, param3){
  //
}
call_me.apply(this, args);

Tags:

C Example