const test = [3, { a: "hello", b: 33 }];
const [x, obj1] = test;
console.log(test); // [3, { a: 33, b: 33 }]
obj1.a = 33;
console.log(test); // [3, { a: 33, b: 33 }]
I am pretty new to JavaScript and this might be something elementary
I noticed that de-structuring an array containing object and reassigning the object reference some other value changes the object itself which is pretty intuitive since the variable obj1 carries reference to the object
My main concern is why does the test array change before the reassignment
This behavior is seen only in the browser running it through node gives expected result