const args = ['p0', 'p1', 'p2'];
call_me.apply(this, args);

See MDN docs for Function.prototype.apply().


If the environment supports ECMAScript 6, you can use a spread argument instead:

call_me(...args);
Answer from KaptajnKold on Stack Overflow
๐ŸŒ
freeCodeCamp
forum.freecodecamp.org โ€บ javascript
Function with array as parameter - JavaScript - The freeCodeCamp Forum
March 11, 2024 - Hi everyone, I am trying to write a function which takes an array and returns a new array with the number of characters in each string from the original array, but it is not working. Only the number of characters of the first string is returned. I am almost sure that this is because the parameter suggests that there is only parameter, rather than an array of parameters, but I am not sure how this should be represented as this is how the original problem was set up and presented to me.
Discussions

how do you pass an array as a parameter in a function?
Michael, I think my solution works better than testing for 'string', 'undefined' and 'number', because in JavaScript there are other types as well, such as boolean, function and object. What's even trickier is that if you use typeof with an array you don't get 'array' as the result; you get ... More on teamtreehouse.com
๐ŸŒ teamtreehouse.com
4
February 23, 2014
Writing a function that takes an array as an argument and sums up all the elements
So close! It's numbers.length not length.numbers And I wouldn't declare y globally. It can be declared just above the for loop. That makes it a pure function . More on reddit.com
๐ŸŒ r/learnjavascript
45
16
July 13, 2022
How to pass an array as argument to a function in javascript? - Stack Overflow
I'm trying to make helper functions to make use of the Google Analytics API, and I have a simple problem building strings. The scenario is, I have to apply a filter, and there may be n number of fi... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Run JS Array/Passing Arrays as Function Arguments
I want to somehow run a JavaScript array โ–ถ Here it is btw Can somebody show me how to run just a array? More on forum.snap.berkeley.edu
๐ŸŒ forum.snap.berkeley.edu
19
0
November 14, 2020
๐ŸŒ
Fjolt
fjolt.com โ€บ article โ€บ javascript-passing-arrays-as-function-parameters
Using an Array as Function Parameter in JavaScript
As such, Javascript provides us with two ways to use arrays as function parameters in Javascript - apply() and the spread operator.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ how-to-pass-an-array-as-a-function-parameter-in-javascript
How to pass an array as a function parameter in JavaScript? - GeeksforGeeks
July 12, 2025 - function unmodifiableFunction(a, b, c) { console.log(`First value is: ${a} Second value is: ${b} Third value is: ${c}`) } arrayToPass = [1, "Two", 3]; unmodifiableFunction.apply(null, arrayToPass); ... The spread operator is used in places where zero or more arguments are expected. It can be used with iterators that expand in a place where there may not be a fixed number of expected arguments (like function parameters).
๐ŸŒ
SamanthaMing
samanthaming.com โ€บ tidbits โ€บ 48-passing-arrays-as-function-arguments
Passing Arrays as Function Arguments | SamanthaMing.com
function sandwich(a, b, c) { console.log(a); // '๐Ÿž' console.log(b); // '๐Ÿฅฌ' console.log(c); // '๐Ÿฅ“' } const food = ['๐Ÿž', '๐Ÿฅฌ', '๐Ÿฅ“']; // Old way sandwich.apply(null, food); // โœ… ES6 way sandwich(...food); ... The ability to turn an array into a list of arguments is super handy with the Math functions.
๐ŸŒ
Team Treehouse
teamtreehouse.com โ€บ community โ€บ how-do-you-pass-an-array-as-a-parameter-in-a-function
how do you pass an array as a parameter in a function? (Example) | Treehouse Community
February 23, 2014 - var arrayCounter = function(array) { if (typeof array === 'string' || typeof array === 'number' || typeof array === 'undefined') { return 0; } else { return array.length; } } Posting to the forum is only allowed for members with active accounts.
๐ŸŒ
DEV Community
dev.to โ€บ smpnjn โ€บ using-an-array-as-function-parameter-in-javascript-33jo
Using an Array as Function Parameter in JavaScript - DEV Community
June 26, 2022 - As such, Javascript provides us with two ways to use arrays as function parameters in Javascript - apply() and the spread operator.
Find elsewhere
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ how-to-pass-arrays-as-function-arguments-in-javascript
How to pass arrays as function arguments in JavaScript?
<html> <body> <script> function shareMar(a, b, c) { document.write(a); document.write("</br>"); document.write(b); document.write("</br>"); document.write(c); } var names = ['NSE', 'BSE', 'NIFTY']; shareMar(...names); </script> </body> </html>
๐ŸŒ
DZone
dzone.com โ€บ data engineering โ€บ data โ€บ using an array as function parameter in javascript
Using an Array as Function Parameter in JavaScript
June 30, 2022 - As such, Javascript provides us with two ways to use arrays as function parameters in Javascript - apply() and the spread operator.
๐ŸŒ
W3Schools
w3schools.com โ€บ js โ€บ js_function_parameters.asp
JavaScript Function Parameters
JavaScript function definitions do not specify data types for parameters. JavaScript functions do not perform type checking on the arguments. JavaScript functions do not check the number of arguments received. Accessing a function with an incorrect parameter can return an incorrect answer:
๐ŸŒ
Delft Stack
delftstack.com โ€บ home โ€บ howto โ€บ javascript โ€บ javascript pass array to function
How to Pass Array to a Function in JavaScript | Delft Stack
February 2, 2024 - It highlights the apply() method, spread operator, arguments object, and the way to pass an entire array to a function as a parameter. The apply() method executes a function with this value and gives arguments as an array or array-like object.
๐ŸŒ
Scientech Easy
scientecheasy.com โ€บ home โ€บ blog โ€บ passing array to function in javascript
Passing Array to Function in JavaScript - Scientech Easy
April 15, 2022 - Similar to C/C++/Java, we can pass the entire array as a parameter to a function in JavaScript. This method of array passing is called call by reference in JavaScript. To pass an array argument to a function, simply pass the name of an array (a reference to an array) without brackets.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnjavascript โ€บ writing a function that takes an array as an argument and sums up all the elements
r/learnjavascript on Reddit: Writing a function that takes an array as an argument and sums up all the elements
July 13, 2022 -

Hi guys I am trying to write a function that takes as an argument an array and then iterates over each element and adds them together but i am having problems, id honestly really appreciate any pointers in the right direction!

this is what I have written so far;

1) Declared y as a global binding.

2) Function takes an array as an argument- (i dont know if "(...argument)" is how you do it).

3)A loop iterates over each element of the array the range of which is 0 - length of array and increments by +1.

4)Each number that is iterated is added to y.

5) y is returned

let y = 0;
function max(...numbers){
for(let x = 0; x < length.numbers; x++){
y += x;
}
return y;
}

console.log(max([1, 2, 3]));
๐ŸŒ
Medium
medium.com โ€บ @sayes2x โ€บ passing-an-array-to-a-function-as-a-value-in-javascript-10c20d5b89
Passing an Array to a Function as a Value in JavaScript | by Scott Price | Medium
October 5, 2018 - When you define a function using a rest parameter, the arguments of the function, no matter how many they are, will be turned into an array. the spread operator allows an iterable, like an array, to be expanded in place.
๐ŸŒ
TA Digital Labs
labs.tadigital.com โ€บ index.php โ€บ 2019 โ€บ 10 โ€บ 21 โ€บ passing-arrays-as-parameters-and-utilizing-them-using-es6-spread
Passing array(s) as parameters and utilizing them using ES6 spread โ€“ TA Digital Labs
November 21, 2019 - The apply() method quickly gained popularity because there were several built-in functions in JavaScript that accepted an arbitrary number of arguments. If we tried passing an array into these functions an error was thrown. var arr = [9, 4, ...
๐ŸŒ
USNA
usna.edu โ€บ Users โ€บ cs โ€บ adina โ€บ teaching โ€บ it350 โ€บ fall2020 โ€บ lectures โ€บ set19-jsFunctionsArrays.html
JavaScript Functions and Arrays
Local variables, visible only inside ... can be created using "new Array()", which creates an empty array, or "new Array(size)", to create an empty array of given size, or just "[]" for an empty array, or "[1,2,3]" for an array initialized with 3 integers....
๐ŸŒ
Snap! Forum
forum.snap.berkeley.edu โ€บ help with snap! โ€บ snap! editor
Run JS Array/Passing Arrays as Function Arguments - Snap! Editor - Snap! Forum
November 14, 2020 - I want to somehow run a JavaScript array โ–ถ Here it is btw Can somebody show me how to run just a array?
๐ŸŒ
freeCodeCamp
forum.freecodecamp.org โ€บ javascript
Parameters and Arguments - JavaScript - The freeCodeCamp Forum
October 25, 2021 - Iโ€™d like to draw someoneโ€™s attention to this question that came up as I was working on the challenge here. Concerning, the logic of the implementation: the function takes two parameters- an array and an item ( a number) CHECK.
๐ŸŒ
Team Treehouse
teamtreehouse.com โ€บ community โ€บ how-do-i-pass-an-array-into-a-function-parameter
How do I pass an array into a function parameter? (Example) | Treehouse Community
February 15, 2015 - function arrayCounter (arr) { //Check to see if the passed in argument is a string, number, or undefined if (typeof arr == "string" || typeof arr == "number" || typeof arr == "undefined") { //If so, return 0, which breaks out of the function ...