JS: Objects
Theory: References
Objects are a reference data type. I.e., variables and constants do not store the objects themselves (their data), but a reference to them. So, it might feel like constants in JavaScript can be changed, but this isn't the case. The main thing to understand is that when it comes to objects, constants are linked with the reference, not the data:
That they are reference data also affects comparison. Objects that have the same structure aren't equal to each other. The only time they can be equal is if they are the same object:
Every object declaration (including an empty one), creates a new object. Therefore, even two empty objects are never equal to each other:
The referential nature of objects affects how they work with functions most of all. Any object passed to a function gets there via a reference. Changing such an object inside a function changes it from the outside as well:

