1
00:00:01,456 --> 00:00:04,706
Let's see this in action in our demo. To

2
00:00:04,706 --> 00:00:06,456
begin with, we define the message object

3
00:00:06,456 --> 00:00:10,456
having a property name with value John.

4
00:00:10,456 --> 00:00:12,456
Next, we have two additional properties,

5
00:00:12,456 --> 00:00:15,820
regular function and arrow function. Each

6
00:00:15,820 --> 00:00:19,092
of these properties has a value that is a

7
00:00:19,092 --> 00:00:20,706
function. In regular function, we print

8
00:00:20,706 --> 00:00:24,789
the string Hello, followed by the value in

9
00:00:24,789 --> 00:00:27,706
this.name. In arrow function, we print the

10
00:00:27,706 --> 00:00:30,123
string Hi, which is, again, followed by

11
00:00:30,123 --> 00:00:33,123
the value in this.name. Finally, we invoke

12
00:00:33,123 --> 00:00:36,456
both these functions, one after another.

13
00:00:36,456 --> 00:00:38,856
In the console, the regular function

14
00:00:38,856 --> 00:00:41,956
prints out Hello John. However, the arrow

15
00:00:41,956 --> 00:00:45,456
function just prints out the string Hi.

16
00:00:45,456 --> 00:00:48,885
This is because when we logout

17
00:00:48,885 --> 00:00:50,313
message.regularFunction, our this keyword

18
00:00:50,313 --> 00:00:52,656
refers to the message object that holds

19
00:00:52,656 --> 00:00:56,581
the function. So when we access this.name,

20
00:00:56,581 --> 00:01:00,170
we get John. Let's print out the value of

21
00:01:00,170 --> 00:01:03,456
this inside the regular function. As you

22
00:01:03,456 --> 00:01:07,456
can see, its value is the message object.

23
00:01:07,456 --> 00:01:10,456
Next, when we call message.arrowFunction,

24
00:01:10,456 --> 00:01:12,856
it looks for the name variable in the

25
00:01:12,856 --> 00:01:15,170
global context, the window object, and

26
00:01:15,170 --> 00:01:18,456
cannot find it. Therefore, only Hi gets

27
00:01:18,456 --> 00:01:22,729
printed to the console. If we try to print

28
00:01:22,729 --> 00:01:25,856
this.name, we get an empty string. If we

29
00:01:25,856 --> 00:01:28,012
try to print just the value of this, we

30
00:01:28,012 --> 00:01:32,456
can see the window object in the console.

31
00:01:32,456 --> 00:01:37,000
That brings us to the end of this module. Let's see what we have covered so far.

