WEBVTT

1
00:00:00.080 --> 00:00:03.180
Now let's start fresh
by removing the existing code.

2
00:00:03.210 --> 00:00:05.740
And today we'll be writing some new code.

3
00:00:05.770 --> 00:00:09.420
One important data structure
in JavaScript are objects.

4
00:00:09.450 --> 00:00:13.860
You can create an object by using curly
braces and adding key value pairs.

5
00:00:13.890 --> 00:00:24.100
For example, we can have a person object
that has a name of Nata, an age of 26.

6
00:00:24.130 --> 00:00:29.480
And if I console log this person,

7
00:00:32.840 --> 00:00:35.060
we're going to get back an object.

8
00:00:35.090 --> 00:00:37.500
Objects allow us to group data together,

9
00:00:37.530 --> 00:00:40.620
including not only variables,
but also functions.

10
00:00:40.640 --> 00:00:44.500
For example, we can create
a greet function here.

11
00:00:44.530 --> 00:00:48.900
Let's create it using arrow functions
that we learned in the previous lesson.

12
00:00:48.930 --> 00:00:51.500
And let's say it console logs:

13
00:00:51.530 --> 00:00:55.900
hi, my name is this name.

14
00:00:55.930 --> 00:00:58.100
Note that this keyword in arrow function

15
00:00:58.130 --> 00:01:01.900
refers to the global scope,
not the object itself.

16
00:01:01.930 --> 00:01:08.100
And to have it referred to the object, we
would have to use traditional function.

17
00:01:08.130 --> 00:01:15.620
So, let's try greeting this person
and the name is going to be undefined.

18
00:01:15.650 --> 00:01:22.490
But because of the difference in this
keyword of the arrow functions

19
00:01:22.520 --> 00:01:28.040
and traditional functions,
we are going to see different results when

20
00:01:28.070 --> 00:01:32.210
we run this file here. This is the syntax
that you'll see throughout this course.

21
00:01:32.240 --> 00:01:35.020
So it's very important that you
recognize and know this.

22
00:01:35.040 --> 00:01:36.680
And I'll see you in the next video where

23
00:01:36.710 --> 00:01:39.460
we're going to be discussing
more about arrays.

24
00:01:39.480 --> 00:01:40.040
Thanks for watching.

