When I have an object defined as such,
const obj = {
first: "hey",
second: "hello"
}
and I do not wish to modify this but create a new object and reassign values to that.
I though doing this should work:
const testObj = obj;
testObj[first] = "heyyy"
However, this causes the original 'obj' object to modify as well. I figured out that using the spread operator will be a solution for this, however, can someone explain why doing testObj = obj, is causing the 'obj' object to be modified every time testObj is modified.