Perhaps my approach is not quite right, so please provide feedback if necessary!
Imagine having an Array that represents some valuable data.
var initial = ['x', 'y'];
var duplicate = initial;
initial.push('z');
console.log(initial === duplicate); // true
I enjoy the fact that both objects remain the same. However, if I were to set initial = ['z']
, this would no longer be the case. Is there a way to maintain this connection while performing additional operations on the array?