Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Clone Array Using Spread Operator

let arr1 = [ 1, 2, 3];
let arr2 = arr1;

console.log(arr1); // [1, 2, 3]
console.log(arr2); // [1, 2, 3]

// append an item to the array
arr1.push(4);

console.log(arr1); // [1, 2, 3, 4]
console.log(arr2); // [1, 2, 3, 4]
Source by www.programiz.com #
 
PREVIOUS NEXT
Tagged: #Clone #Array #Using #Spread #Operator
ADD COMMENT
Topic
Name
6+3 =