Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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 ]
Comment

PREVIOUS NEXT
Code Example
Javascript :: spread operator react array 
Javascript :: .unshift 
Javascript :: js arrow function vs function 
Javascript :: js a function that takes in multiple arguments. 
Javascript :: js octal 
Javascript :: javascript print square 
Javascript :: determine location of ip address nodejs 
Javascript :: alertify js examples 
Javascript :: Default Parameter Values in javascript 
Javascript :: discord message reply 
Javascript :: know when recyclerview is on the last item 
Javascript :: maximum number of an array 
Javascript :: save image on cloudinary 
Javascript :: discord.js command cooldown 
Javascript :: javascript find ip and information 
Javascript :: jquery set timezone 
Javascript :: how to name a file path in document.geteleementbyid 
Javascript :: angular conditional tooltip 
Javascript :: delete div based on select 
Javascript :: add a string to list jquery 
Javascript :: javascript bigdecimal 
Javascript :: How to put anything as log in console 
Javascript :: express fingerprint 
Javascript :: mock anonymous function jest 
Javascript :: get id value in javascript 
Python :: francais a anglais 
Python :: selenium Keys enter python 
Python :: Import "reportlab" could not be resolved django 
Python :: python argparse ignore unrecognized arguments 
Python :: Colorcodes Discord.py 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =