1
00:00:01,569 --> 00:00:06,730
In the previous video, we saw how we were able to structure a ray in this video.

2
00:00:06,760 --> 00:00:09,580
Let's see how we can structure objects.

3
00:00:09,580 --> 00:00:12,100
And it's called object destruction.

4
00:00:12,490 --> 00:00:19,420
So let's have an example icons or BG as my object with some few properties.

5
00:00:19,480 --> 00:00:26,440
And let's say the first property is going to be first name and as before as John.

6
00:00:26,560 --> 00:00:34,630
And let's say the edge of this object is or the name or the age of this person is 24.

7
00:00:35,170 --> 00:00:40,980
So now we can get the properties from this object in two ways using a dot notation, right?

8
00:00:40,990 --> 00:00:53,290
We can make use of object dots h or dots first name as before, or we can use the bracket notation inside.

9
00:00:53,290 --> 00:00:56,350
I have my age and then I have my first name.

10
00:00:56,710 --> 00:01:04,269
So let's see how we can achieve the same logic using the new feature in JavaScript code destruction.

11
00:01:04,420 --> 00:01:13,900
So the same way as we did for arrays, you bring in your cost and your basis and it's equal to the object

12
00:01:13,900 --> 00:01:14,670
as that.

13
00:01:14,680 --> 00:01:18,540
And in here we can pool the individual property.

14
00:01:18,550 --> 00:01:22,870
So I want the first name is sorry is.

15
00:01:22,870 --> 00:01:23,280
Yeah.

16
00:01:23,440 --> 00:01:24,340
Like this one.

17
00:01:24,590 --> 00:01:30,050
I want the first name and then the last name for object destruction.

18
00:01:30,100 --> 00:01:32,170
The order doesn't matter.

19
00:01:32,200 --> 00:01:32,650
Right.

20
00:01:32,650 --> 00:01:37,540
But for the arrays, the order we need to pay attention to it matters a lot.

21
00:01:37,840 --> 00:01:43,030
Okay, so here the first one, first name represent the value for this one.

22
00:01:43,030 --> 00:01:49,510
So inside my console here, if I said for first name, you're going to see I have John if I want set

23
00:01:49,510 --> 00:01:51,460
for H, I have 24.

24
00:01:52,150 --> 00:01:58,210
One cool thing I like about object destruction is that I can rename my property name.

25
00:01:58,210 --> 00:02:02,200
So let's say that for the first name I want to change this one to let's say anything.

26
00:02:02,440 --> 00:02:06,700
So what I need to do is I'll bring colon and the my variable name.

27
00:02:06,700 --> 00:02:08,949
I can make this or let's say my name.

28
00:02:09,340 --> 00:02:12,460
So now I have renamed the first name to my name.

29
00:02:12,460 --> 00:02:16,540
So if I check for my name here, you see I see John.

30
00:02:16,540 --> 00:02:22,750
If I check for first name, let's see if it will retain first name.

31
00:02:23,760 --> 00:02:28,800
You see, I get undefined because I have renamed it to my name.

32
00:02:29,100 --> 00:02:30,820
The same thing applies to age.

33
00:02:30,840 --> 00:02:34,500
I can say this is going to be as my h.

34
00:02:34,710 --> 00:02:41,040
So inside the console if I search for my h, i have 24.

35
00:02:41,220 --> 00:02:44,430
That is the object destruction.

36
00:02:44,640 --> 00:02:52,590
Well, the next video I will show you how we can add some default values when we are destruction and

37
00:02:52,590 --> 00:02:53,220
object.

