However, this is not what happens with objects and their properties. Here’s another example:
This StackOverflow answer calls this “call-by-sharing”. Changing the internals of an object mutates the original object.
Two of my preferred solutions for this, depending on your development environment (browser or server), are to use Object.assign or the ES6 spread operator: