Object are passed with their reference in javascript. Meaning change in that object from any where should be reflected. In this case, the expected output was {} for console.log(
Okay, so you've figured out that JavaScript objects have reference semantics, so modifying a referent has an effect on the same object in the original scope.
What you also need to realise is that =
is not part of these rules; not only does it perform assignment, but it will also rebind the reference to a new object.
Under the hood, so to speak, that's basically how your original references were formed.