that assigns one array to another (i believe they refer to it as being ‘by reference’?), which is not the same as a copy.
you could use newArray=array.map((x)=>x)
that copies each individual value to create a new array
so are you saying that what I am doing with newArr is basically creating a reference to arr2, and if newArr changes so does arr2? Thanks for the reply by the way.
You’ve got it right.
Primitive types (strings, numbers, booleans, ‘undefined’, ‘null’) are copied by value, but objects (everything else is a type of object) are copied by reference.
let num1 = 42;
let num2 = num1;
num1 = 69;
console.log(num1); // 69
console.log(num2); // 42
let arr1 = ['a', 'b', 'c'];
let arr2 = arr1; // there is one array in memory that both of these variables link to
arr1.push('d');
arr2.push('cheese');
console.log(arr1); // ['a', 'b', 'c', 'd', 'cheese']
console.log(arr2); // ['a', 'b', 'c', 'd', 'cheese']