What do I mean by objects are passed by reference and not copied? Well, this is an important concept to understand. If you are creating, quote unquote copies of objects, the best way to explain it is to show an example. So let me open up the console. Once again, I'm going to create our object. I have a number of different properties in that object and a method.
Now let's say I wanted a copy of this object. So I could do something like this. User one equals user. Now if I display user, it looks like this. We can open that up and see everything in that object. If I display user one.
It looks like this. looks exactly the same. And that might lead you to think, well now I have two copies. Well, that is not completely true. Basically, these variables are simply references to an object, this object is stored in memory somewhere. And these variables reference that.
And that's important to remember because if you change something about one, it will change it about the other because they point to the same object. So for example, let's write now the age is set to 32. So let me change user dot age and set that equal to 33. Now Now if I display user, we can see age is 33. How about if we display user one ages also 33 so it changed it for both. And the reason it does that is once again, we did not create a copy, we don't have two separate objects, we have a single object stored in memory.
And then these variables are referencing that same object. So very important concept to remember if you ever create more than one reference to an object, simply remember, it is not a copy of that object. If you wanted a separate copy, then we would have to execute our original command where we created it, assign it to a different variable. Now user two is of course its own object. Alright, let's move on to the next section.