Answers for "passing array to function in javascript by value"

C
0

passing an array to a function

/**
* myFunction - receives an array param of 10 int variables
*/

void myFunction(int param[10]) {
   .
   .
   .
}
Posted by: Guest on August-04-2021
0

javascript pass array by value

// example of pass array by value 
let arr = [ 1 , 2 , 3 ];

// new Array => constructor take args & make array using it
// ...arr => just extract all array elements in this place
let arr_copy = new Array( ...arr );  // pass by value

arr_copy[0] = 99; // proof :)

console.log( arr ); 	 // output => [ 1  , 2 , 3 ]
console.log( arr_copy ); // output => [ 99 , 2 , 3 ]
Posted by: Guest on October-27-2021

Code answers related to "passing array to function in javascript by value"

Code answers related to "C"

Browse Popular Code Answers by Language