1
00:00:00,450 --> 00:00:01,500
In this video.

2
00:00:01,500 --> 00:00:06,810
Let's dive in more to explain what this key word mean.

3
00:00:07,110 --> 00:00:12,450
Well, this is advanced topic in JavaScript, but I'm teaching it as basic.

4
00:00:12,450 --> 00:00:16,710
Right, because I'm going to break it down for you to understand.

5
00:00:17,010 --> 00:00:20,580
And again, I'm going to repeat ourself as you move on.

6
00:00:20,580 --> 00:00:24,110
So let me give you the overview of this keyword.

7
00:00:24,120 --> 00:00:26,160
So now moment of truth.

8
00:00:26,370 --> 00:00:28,290
So what is this?

9
00:00:29,370 --> 00:00:32,880
So let me come up here, okay?

10
00:00:32,910 --> 00:00:33,720
We can build something.

11
00:00:33,720 --> 00:00:36,060
So let's say the.

12
00:00:36,060 --> 00:00:37,230
This keyword.

13
00:00:38,310 --> 00:00:40,680
This keyword.

14
00:00:42,170 --> 00:00:42,830
All right.

15
00:00:43,700 --> 00:00:45,170
So what is it?

16
00:00:45,320 --> 00:00:51,410
So in JavaScript this keyword refers to an object.

17
00:00:51,620 --> 00:00:53,650
The first thing bear in mind.

18
00:00:53,660 --> 00:00:56,060
So let me remove the calling here.

19
00:00:56,990 --> 00:01:03,020
One thing in mind is that in JavaScript the this refers to an object.

20
00:01:04,959 --> 00:01:10,930
And then the objects would differ depending on how it is used.

21
00:01:11,680 --> 00:01:21,520
So if you use this key word in an object that this keyword represents the instance of the particular

22
00:01:21,520 --> 00:01:24,250
object that is being operated on.

23
00:01:24,790 --> 00:01:29,350
So remember, we see that we are using this key word here.

24
00:01:29,830 --> 00:01:39,220
So this key words represent what the immediate or the current object this object is being depending

25
00:01:39,220 --> 00:01:39,780
on.

26
00:01:39,790 --> 00:01:46,780
And this key word is depending on the immediate method, which is called object.

27
00:01:47,230 --> 00:01:49,570
Because we have dots after that.

28
00:01:49,810 --> 00:01:53,920
So this is a method, this function, this keyword is referring to.

29
00:01:54,940 --> 00:01:55,290
The gate.

30
00:01:55,330 --> 00:01:58,240
And this object is the one above here.

31
00:01:59,500 --> 00:02:00,130
Do you get it?

32
00:02:00,160 --> 00:02:01,450
That's the first scenario.

33
00:02:02,320 --> 00:02:07,990
And then we can also console.log objects on its own.

34
00:02:08,020 --> 00:02:11,460
So let's just say console.log.

35
00:02:11,980 --> 00:02:12,640
This.

36
00:02:13,480 --> 00:02:14,200
Check it out.

37
00:02:14,800 --> 00:02:18,670
If I save it now, we get something will happen here.

38
00:02:18,940 --> 00:02:19,660
The same.

39
00:02:19,660 --> 00:02:24,460
This key word is representing the global object.

40
00:02:25,610 --> 00:02:36,620
Remember, the global object is the entire object of the browser or even the environment where JavaScript

41
00:02:36,620 --> 00:02:39,830
is being executed, and that is the browser.

42
00:02:40,250 --> 00:02:43,400
You see, we have a bunch of methods we have here.

43
00:02:43,520 --> 00:02:47,900
So this keyword differs depending where it is used.

44
00:02:48,140 --> 00:02:52,760
Because if you look at this, do we have dots before this?

45
00:02:52,940 --> 00:02:53,600
No.

46
00:02:55,000 --> 00:02:57,580
Yes, we have it, but I don't know.

47
00:02:57,700 --> 00:03:02,470
So this one is the same as window object.

48
00:03:03,340 --> 00:03:07,750
If I save this one, you see, I get the same thing.

49
00:03:09,290 --> 00:03:16,070
If I make use of window doors, this meaning we have on to find.

50
00:03:17,100 --> 00:03:24,780
Meaning that the window represents that this key word when is being alone.

51
00:03:24,990 --> 00:03:27,750
For the meantime, don't worry about this logic for now.

52
00:03:27,780 --> 00:03:31,800
So what I'm trying to conclude here is that.

53
00:03:32,540 --> 00:03:38,770
Don't worry myself by understanding details what these kids are referring to right now.

54
00:03:38,780 --> 00:03:46,610
Take it that wherever you see this, the object that is being operated on is this key word.

55
00:03:46,970 --> 00:03:55,250
And if this key word is being used in a global context like this one, it refers to the global object.

56
00:03:55,990 --> 00:04:01,690
And again if you get back to don't manipulation and let's see how we can handle event.

57
00:04:01,870 --> 00:04:06,370
The button that you click on refers to the object that this keyword.

58
00:04:06,940 --> 00:04:08,200
So don't worry about that.

59
00:04:08,380 --> 00:04:15,730
So take away here in this particular video is that understand that whenever we see person an object

60
00:04:15,760 --> 00:04:22,900
that comes after this keyword or refer to the person that particular object to more precise.

61
00:04:23,140 --> 00:04:27,010
So now that we've got this one right, we can also.

62
00:04:27,800 --> 00:04:32,480
I object in a different way than coming down here after the objects.

63
00:04:32,480 --> 00:04:36,560
And then we also add the objects they maintain here.

64
00:04:37,010 --> 00:04:39,210
We can do it, but we also do it in line.

65
00:04:39,240 --> 00:04:40,120
The same thing.

66
00:04:40,130 --> 00:04:45,920
I can add the method in line with the properties inside.

67
00:04:46,070 --> 00:04:48,710
So how can we also do that?

68
00:04:49,010 --> 00:04:50,890
It's pretty simple to do.

69
00:04:51,210 --> 00:05:00,470
All I need is provide, let's say full name here, full name and then semicolon, then my function name.

70
00:05:01,220 --> 00:05:02,090
Remember?

71
00:05:03,130 --> 00:05:05,740
Don't use arrow function.

72
00:05:06,220 --> 00:05:11,820
If we want to have this keyword arrow function, don't bind this keyword.

73
00:05:11,830 --> 00:05:18,060
If a familiar arrow function well, that is why I'm letting you know by following the arrow function.

74
00:05:18,070 --> 00:05:23,950
Don't worry, if you get back to new features in JavaScript, you talk about new features like map for

75
00:05:23,950 --> 00:05:27,040
each arrow, function, destruction and many more.

76
00:05:27,280 --> 00:05:33,280
For the meantime, use normal function, keyword like function and incredibly don't use arrow function.

77
00:05:33,280 --> 00:05:35,950
Otherwise this keyword does not bind.

78
00:05:35,980 --> 00:05:38,620
The arrow function doesn't bind to this keyword.

79
00:05:39,010 --> 00:05:39,790
Take note here.

80
00:05:39,790 --> 00:05:40,900
So the same thing.

81
00:05:40,900 --> 00:05:42,520
I can copy my function here.

82
00:05:42,520 --> 00:05:45,670
What is inside here and then here.

83
00:05:45,700 --> 00:05:46,870
Now I can comment.

84
00:05:46,870 --> 00:05:49,300
This one out is the same.

85
00:05:50,050 --> 00:05:57,090
So if I check for foo name we see that I get full name over here.

86
00:05:57,610 --> 00:06:03,910
So that is it about I mean how we can add custom method on that.

87
00:06:04,390 --> 00:06:09,700
So before we end up this video, let me give you some critical example here or some demo here.

88
00:06:10,150 --> 00:06:18,940
Let's take that where for this object, let's check if the person is titles like let's say false here.

89
00:06:19,900 --> 00:06:20,890
Yeah, for here.

90
00:06:21,610 --> 00:06:24,280
Let's let's say that for this person object.

91
00:06:24,280 --> 00:06:27,550
You want to check or create a function or method to check.

92
00:06:28,090 --> 00:06:34,390
If the person status is false, then we want to delete the admin property.

93
00:06:34,840 --> 00:06:36,730
How can we do it?

94
00:06:37,000 --> 00:06:42,580
Okay, so let's say let's add our function here in line with this one.

95
00:06:42,580 --> 00:06:46,180
Let's say check.

96
00:06:47,620 --> 00:06:48,460
Starters.

97
00:06:50,010 --> 00:06:52,530
Now semicolon then my function name.

98
00:06:53,720 --> 00:06:55,760
Is that and is that?

99
00:06:56,700 --> 00:06:57,760
So let's check.

100
00:06:57,790 --> 00:06:58,850
So if.

101
00:06:59,790 --> 00:07:01,890
This dirt.

102
00:07:02,950 --> 00:07:04,120
Start us.

103
00:07:05,740 --> 00:07:06,400
If.

104
00:07:07,240 --> 00:07:11,200
It's not equal to true.

105
00:07:11,230 --> 00:07:13,150
Or if it's equal to force.

106
00:07:13,150 --> 00:07:13,800
Yes.

107
00:07:13,810 --> 00:07:22,330
If it's equal to force, then we can go ahead and then let's say we won't delete the person.

108
00:07:22,960 --> 00:07:26,230
The person the person is admin delete.

109
00:07:26,230 --> 00:07:28,510
What's the this.

110
00:07:29,140 --> 00:07:32,080
Because I want access to the person's admin here.

111
00:07:32,200 --> 00:07:34,420
So this dot.

112
00:07:35,690 --> 00:07:37,700
Is admin.

113
00:07:39,050 --> 00:07:41,370
So if I save this one now.

114
00:07:41,390 --> 00:07:42,360
Moment of truth.

115
00:07:42,380 --> 00:07:44,180
Let me comment this one out here.

116
00:07:45,200 --> 00:07:49,040
Now, let's check the entire object person.

117
00:07:50,270 --> 00:07:51,500
Do we have?

118
00:07:51,680 --> 00:07:54,680
Is admin inside or is still here?

119
00:07:54,680 --> 00:08:00,460
Because I haven't called a function because having quite a few I still see it's admin here.

120
00:08:00,650 --> 00:08:01,450
I won't delete it.

121
00:08:01,460 --> 00:08:01,970
Right.

122
00:08:02,420 --> 00:08:04,490
So let's call the function down here.

123
00:08:05,000 --> 00:08:12,860
So person dot check check status as a function like this one.

124
00:08:12,860 --> 00:08:16,370
If I save this one now, let's check the person.

125
00:08:19,280 --> 00:08:19,940
Do we see?

126
00:08:19,940 --> 00:08:21,170
It's been here.

127
00:08:21,680 --> 00:08:22,520
It's gone.

128
00:08:23,180 --> 00:08:32,750
Or we can even change the property to, let's say, false or or true or whatever.

129
00:08:33,210 --> 00:08:35,840
You know, this logic is mostly used.

130
00:08:35,870 --> 00:08:38,179
Let's take, let's say YouTube, for example.

131
00:08:38,840 --> 00:08:41,210
You see YouTube always check that.

132
00:08:41,210 --> 00:08:46,940
Let's say that if you have some number of subscribers, then they can give you or they can put you on

133
00:08:46,940 --> 00:08:48,470
their monetization program.

134
00:08:48,710 --> 00:08:51,440
So this way we can also do something here.

135
00:08:51,650 --> 00:08:54,260
So we can say that if.

136
00:08:55,340 --> 00:08:55,590
Okay.

137
00:08:55,700 --> 00:09:00,630
Let me say that if your age is more is less than or more than 30.

138
00:09:00,660 --> 00:09:01,210
Okay, let me see.

139
00:09:01,210 --> 00:09:03,380
Accounts we use count.

140
00:09:03,410 --> 00:09:07,310
Yes, we use count, let's say is equal to 100.

141
00:09:08,560 --> 00:09:09,030
Okay.

142
00:09:09,430 --> 00:09:15,700
So let's create a function to check if your view count is less than 50.

143
00:09:15,730 --> 00:09:20,110
Then we can put you on the monetization program.

144
00:09:20,260 --> 00:09:20,860
Right.

145
00:09:20,860 --> 00:09:24,130
So can you do something about this one to make something happen?

146
00:09:24,430 --> 00:09:26,860
Well, I think this video is getting longer.

147
00:09:26,890 --> 00:09:28,810
So if want to try this one, why not?

148
00:09:28,840 --> 00:09:34,090
Or better still, sit down and think about a method that you can use on an object.

149
00:09:34,090 --> 00:09:34,480
Right?

150
00:09:34,480 --> 00:09:39,010
Because in the upcoming ones, we're going to have a lot of coding challenges.

151
00:09:39,010 --> 00:09:41,560
So stick back in this video.

152
00:09:41,590 --> 00:09:46,090
Let's talk about how we can attract over objects then this video.

