Add and remove items, then see that assigning an array copies the reference, not the array. Spread makes a real copy.
JavaScript · beginner · 6 min · 9 steps · free
const fruits = ['apple', 'banana'];
fruits.push('cherry');
const first = fruits[0];
const last = fruits.pop();
const sameList = fruits;
sameList.push('mango');
const copy = [...fruits];
copy.push('kiwi');
console.log(fruits, copy);fruits is created and points to a new Array: ["apple", "banana"].push adds to the end of the same array. fruits is a const, but const only stops reassigning the variable, not changing the array.first is created with the value "apple".pop removes the last item and returns it.sameList = fruits copies the arrow, not the array: both names point to one array.sameList changes the one shared array.[...fruits] spreads the items into a brand-new array: a real copy.[ 'apple', 'banana', 'mango' ] [ 'apple', 'banana', 'mango', 'kiwi' ].Answer: Yes. The array changes, not the variable.
Answer: Yes
← Functions as Values: Callbacks · map, filter, reduce and find →