In the previous video, we saw how we were able to structure a ray in this video.
Let's see how we can structure objects.
And it's called object destruction.
So let's have an example icons or BG as my object with some few properties.
And let's say the first property is going to be first name and as before as John.
And let's say the edge of this object is or the name or the age of this person is 24.
So now we can get the properties from this object in two ways using a dot notation, right?
We can make use of object dots h or dots first name as before, or we can use the bracket notation inside.
I have my age and then I have my first name.
So let's see how we can achieve the same logic using the new feature in JavaScript code destruction.
So the same way as we did for arrays, you bring in your cost and your basis and it's equal to the object
as that.
And in here we can pool the individual property.
So I want the first name is sorry is.
Yeah.
Like this one.
I want the first name and then the last name for object destruction.
The order doesn't matter.
Right.
But for the arrays, the order we need to pay attention to it matters a lot.
Okay, so here the first one, first name represent the value for this one.
So inside my console here, if I said for first name, you're going to see I have John if I want set
for H, I have 24.
One cool thing I like about object destruction is that I can rename my property name.
So let's say that for the first name I want to change this one to let's say anything.
So what I need to do is I'll bring colon and the my variable name.
I can make this or let's say my name.
So now I have renamed the first name to my name.
So if I check for my name here, you see I see John.
If I check for first name, let's see if it will retain first name.
You see, I get undefined because I have renamed it to my name.
The same thing applies to age.
I can say this is going to be as my h.
So inside the console if I search for my h, i have 24.
That is the object destruction.
Well, the next video I will show you how we can add some default values when we are destruction and
object.