Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js array copy not reference

let arr1 = [1,2,3,4,5]

let arr2 = arr1 // copies the reference of the array
arr2 = [...arr1] // copies the values of the array
 
PREVIOUS NEXT
Tagged: #js #array #copy #reference
ADD COMMENT
Topic
Name
2+3 =