So objects like a raise have a separate operator that allow you to break an object apart.
So here's a couple of things you can do.
You can say let an object equals and then in curly braces, use the spread operator, dot, dot, dot
myod, which is another object and it makes it clone.
And just like with a raise, if you say let OB's equals myod, it's just going to be another pointer
to the same object.
So if you do a clone, it makes a copy of it, but only does a shallow copy.
So if you have objects within objects with an object, it's only going to copy the upper level
and then you can merge two objects.
You can say that an object equals dot, dot, dot, obj, one dot, dot, dot, object two.
So it makes one object out of two objects.
So let's look at a couple examples.
All right.
So let's create an object and we'll just say let
object equals and we'll say name Bill, age thirty three.
We don't have to supply a lot of information.
So then just to demonstrate, if we say let my object equals OBJ and then say in my obj that age plus
plus a year has gone by and we said cancel that log.
The original object that we see is that it's going to be thirty four.
Let's take a look.
So now Bill is 34, so both objects are the same.
So if we did it instead with the spread operator, if we said curly brace, dot, dot, dot, curly
brace, and we'll output both OBJ and my abs.
Now we see we have a bill whose age is 33 and a bill whose age is thirty four.
Now, what about having a deep definition?
So if we say have a set object profession, name
carpenter
and.
Experience, two years.
So now we have more of a deeper object.
So now what happens if we do this?
So we have the same thing.
So if we go into my arms and change the experience.
Firsthand experience plus plus.
So see that this one's three and this one's also three, so it only made a shallow copy.
So profession is as if we did what we did originally and said biologicals or object is my art.
So this thing did not get cloned, so you'd have to clone each part.
So now let's merge two objects.
So instead of it being like this, let's make another object
and say what profession equals and.
So now we have two objects, so now if we said object that that profession, then my arms would be both
of them.
So we can't do this, but we could do my abs.
That experience crosspost.
So let's see what happens.
The name here is the same in both, so we're going to get a collision, so let's change this to P name,
profession, name.
And so now we have named Bill, age 34 penname as carpenter and experiences three.
So that's an introduction to the spread operator with objects.