How do references differ from values in JavaScript?
The reason is that the assignment copies the reference and not the object. The object itself lives in memory somewhere, and both variables end up holding a pointer to that same place. There is only ever one object in memory, and both names are simply two labels for it.
The result of that is that a change made through one name is visible through the other. If you set a property on the second variable, the first variable sees it too, because the two of them are looking at the same object. If you instead replace the whole variable with a brand new object, then the other name still points at the original object.
To make a genuinely separate copy you have to ask for one in a clear way. The spread operator inside an object literal makes a shallow copy, so the top level is new but the values nested inside are still shared. The structuredClone function makes a deep copy, so everything inside is copied too. The Object.assign method also makes a shallow copy, and the difference is that it copies into a target object that you give it, which makes it useful when you want to merge several sources into one.
Two practical consequences are worth keeping in mind when you review code. If a function receives an object and changes it, then the caller sees that change, which is surprising unless the function says so in its documentation. And if you are storing an object in state and you want to keep the old value so that you can compare it later, you have to copy it at the exact moment of the update, because storing the reference gives you the very same object twice.