1
00:00:00,390 --> 00:00:09,060
So let's see how we can delete properties of an object and we can do it in two ways using the dot notation

2
00:00:09,060 --> 00:00:11,900
and using the bracket notation.

3
00:00:11,910 --> 00:00:14,940
So let me comment this one and my object.

4
00:00:14,940 --> 00:00:17,550
Copy it and let me comment that one.

5
00:00:18,300 --> 00:00:24,450
Then come down here, let's say deleting object property.

6
00:00:27,290 --> 00:00:28,940
Deleting objects.

7
00:00:30,500 --> 00:00:31,400
Properties.

8
00:00:34,810 --> 00:00:35,290
Yes.

9
00:00:35,290 --> 00:00:36,010
So here we go.

10
00:00:36,040 --> 00:00:37,870
Let me paste my object here.

11
00:00:37,990 --> 00:00:40,270
So how can we do it?

12
00:00:40,300 --> 00:00:42,550
So let's use the.

13
00:00:42,580 --> 00:00:46,150
Using the dot.

14
00:00:47,320 --> 00:00:48,270
In rotation.

15
00:00:50,290 --> 00:00:50,890
Let's see.

16
00:00:50,920 --> 00:00:55,270
So let's say delete the person.

17
00:00:55,310 --> 00:01:02,710
Okay, let me say let me add some more confidential property, for example, is what?

18
00:01:03,520 --> 00:01:04,959
Let's see.

19
00:01:05,860 --> 00:01:06,400
Okay.

20
00:01:06,430 --> 00:01:06,950
It's okay.

21
00:01:06,970 --> 00:01:08,410
I don't want to be more personal here.

22
00:01:08,890 --> 00:01:09,540
So delete the.

23
00:01:09,580 --> 00:01:11,860
Delete the H, the H property.

24
00:01:12,340 --> 00:01:14,320
The H property.

25
00:01:15,310 --> 00:01:15,940
Yes.

26
00:01:16,150 --> 00:01:16,440
Good.

27
00:01:16,450 --> 00:01:20,980
So all what we need is you bring in delete.

28
00:01:21,010 --> 00:01:24,520
This is a special keyword in JavaScript.

29
00:01:24,730 --> 00:01:26,710
Delete as that.

30
00:01:27,160 --> 00:01:30,190
This variable is known as who made it.

31
00:01:30,190 --> 00:01:32,290
So name it as delete.

32
00:01:32,590 --> 00:01:34,110
And then what do you want?

33
00:01:34,130 --> 00:01:34,720
Delete.

34
00:01:35,170 --> 00:01:39,160
So I will take the person dart edge.

35
00:01:40,300 --> 00:01:41,140
That is it.

36
00:01:41,440 --> 00:01:43,120
So I have deleted it.

37
00:01:43,120 --> 00:01:54,940
So if I check my console here, then if I search for person record, do I have h init h is gone.

38
00:01:55,090 --> 00:02:01,270
It's nowhere to be found, but h is here in the original array, in the original object.

39
00:02:01,570 --> 00:02:02,350
You see that?

40
00:02:02,530 --> 00:02:10,660
So even after this one, one good thing you need to bear in mind understand why objects are parsed by

41
00:02:10,660 --> 00:02:16,030
reference is that if we see that we have deleted this h.

42
00:02:16,250 --> 00:02:16,830
Okay.

43
00:02:16,840 --> 00:02:27,460
So if I console.log again, this person are not able to see the H because behind the scene it has remove

44
00:02:27,460 --> 00:02:28,210
it from here.

45
00:02:28,540 --> 00:02:30,220
That is one method.

46
00:02:30,580 --> 00:02:34,690
What about using the bracket notation?

47
00:02:35,440 --> 00:02:38,470
So using the bracket.

48
00:02:40,590 --> 00:02:50,220
Notation also asks you bring delete and then person square bracket single or double code and let's say

49
00:02:50,250 --> 00:02:52,110
hobbies remove that.

50
00:02:52,110 --> 00:02:57,960
So let me comment this one out here and now let's see, check the person.

51
00:02:57,990 --> 00:02:59,520
Do we have hobbies in it?

52
00:03:00,340 --> 00:03:00,910
No.

53
00:03:00,940 --> 00:03:03,130
Everything is gone forever.

54
00:03:03,550 --> 00:03:07,900
So you may be asking, what are some of the use cases?

55
00:03:08,110 --> 00:03:08,380
Okay.

56
00:03:08,610 --> 00:03:14,500
Let me show you one thing here we can say is admit to true.

57
00:03:15,040 --> 00:03:29,150
And then let's say that the person let me say starters, for example, let's say A is not verify.

58
00:03:29,200 --> 00:03:30,880
Okay, let's say not.

59
00:03:31,790 --> 00:03:32,870
Verify.

60
00:03:34,110 --> 00:03:43,800
So we can make a logic that where you want to check inside this object, a person object, if the person

61
00:03:43,800 --> 00:03:50,340
status is not verified, then we are going to remove this property called is admin.

62
00:03:51,500 --> 00:03:52,410
It's admin.

63
00:03:52,430 --> 00:03:57,170
So that is why we need method to make something like this happen.

64
00:03:57,650 --> 00:04:04,940
So in this video, I'm going to show you how we can add our custom methods to object so that we can

65
00:04:04,940 --> 00:04:09,860
do more logic in any way that we want.

