1
00:00:02,320 --> 00:00:05,700
Arrays are a very useful data type,

2
00:00:05,700 --> 00:00:07,939
a very useful kind of value for

3
00:00:07,939 --> 00:00:10,410
storing related data

4
00:00:10,410 --> 00:00:13,780
that can be expressed as a list of data.

5
00:00:13,780 --> 00:00:16,570
Basically, just as we had lists in HTML

6
00:00:16,570 --> 00:00:20,433
you could say for outputting related list data.

7
00:00:21,310 --> 00:00:24,915
Sometimes we also have other kinds of related data

8
00:00:24,915 --> 00:00:26,801
which is not just a list

9
00:00:26,801 --> 00:00:28,390
but which

10
00:00:28,390 --> 00:00:29,250
is related,

11
00:00:29,250 --> 00:00:31,450
but needs more context,

12
00:00:31,450 --> 00:00:35,420
so which is not just a list of equal values;

13
00:00:35,420 --> 00:00:37,850
these are all hobbies after all

14
00:00:37,850 --> 00:00:40,750
but instead multiple connected values

15
00:00:40,750 --> 00:00:43,730
that describe different things.

16
00:00:43,730 --> 00:00:45,330
Sounds very abstract.

17
00:00:45,330 --> 00:00:48,620
Let's consider a passport or an ID.

18
00:00:48,620 --> 00:00:49,453
This here,

19
00:00:49,453 --> 00:00:50,780
for example, is the German

20
00:00:51,900 --> 00:00:52,733
ID,

21
00:00:52,733 --> 00:00:55,290
but you have something like this for

22
00:00:55,290 --> 00:00:57,650
every country in the world, I would assume.

23
00:00:57,650 --> 00:01:00,310
And the interesting thing here is that

24
00:01:00,310 --> 00:01:04,620
this of course describes related data in the end,

25
00:01:04,620 --> 00:01:07,530
but we have labels that tell us

26
00:01:07,530 --> 00:01:09,840
which piece of data

27
00:01:09,840 --> 00:01:13,290
describes which trait of this person.

28
00:01:13,290 --> 00:01:14,123
So for example,

29
00:01:14,123 --> 00:01:16,950
we have a label for the name and then we have to value

30
00:01:16,950 --> 00:01:19,148
the actual name of this person.

31
00:01:19,148 --> 00:01:21,480
Last name and the first name,

32
00:01:21,480 --> 00:01:24,140
we have to date of birth and so on.

33
00:01:24,140 --> 00:01:26,140
And we always have these labels

34
00:01:26,140 --> 00:01:29,880
and then the values for these labels.

35
00:01:29,880 --> 00:01:30,870
And overall,

36
00:01:30,870 --> 00:01:31,703
of course,

37
00:01:31,703 --> 00:01:34,910
we can clearly say that this is related data,

38
00:01:34,910 --> 00:01:36,720
all these different pieces of data,

39
00:01:36,720 --> 00:01:39,430
describe one person,

40
00:01:39,430 --> 00:01:41,960
but it's not a list of data because

41
00:01:41,960 --> 00:01:43,970
it's not the same kind of data.

42
00:01:43,970 --> 00:01:45,180
We have names,

43
00:01:45,180 --> 00:01:46,013
dates,

44
00:01:46,013 --> 00:01:46,846
countries,

45
00:01:46,846 --> 00:01:47,730
cities,

46
00:01:47,730 --> 00:01:49,390
different kinds of data on there.

47
00:01:49,390 --> 00:01:51,660
So it's not the same as a list of hobbies

48
00:01:52,720 --> 00:01:54,890
and to describe such kind of data

49
00:01:54,890 --> 00:01:56,400
as well in JavaScript,

50
00:01:56,400 --> 00:01:58,990
we have another important data type,

51
00:01:58,990 --> 00:02:02,100
another important value we can create.

52
00:02:02,100 --> 00:02:05,230
And that would be objects.

53
00:02:05,230 --> 00:02:06,280
Let's say

54
00:02:06,280 --> 00:02:07,113
our

55
00:02:07,113 --> 00:02:10,300
user who visits this website has

56
00:02:10,300 --> 00:02:11,410
a job,

57
00:02:11,410 --> 00:02:15,100
but a job is not just a string where we say

58
00:02:16,410 --> 00:02:17,243
developer,

59
00:02:17,243 --> 00:02:18,090
for example,

60
00:02:18,090 --> 00:02:18,923
but instead,

61
00:02:18,923 --> 00:02:22,930
the job could be a combination of different values,

62
00:02:22,930 --> 00:02:24,910
where we have the name of the company,

63
00:02:24,910 --> 00:02:29,390
the place where he or she works and so on.

64
00:02:29,390 --> 00:02:32,020
And for that, we could create such an object.

65
00:02:32,020 --> 00:02:36,730
We do that with curly braces after this equal sign here.

66
00:02:36,730 --> 00:02:39,423
So opening and closing curly brace,

67
00:02:40,410 --> 00:02:42,370
and between those curly braces,

68
00:02:42,370 --> 00:02:45,080
we now put the different

69
00:02:45,080 --> 00:02:47,290
properties of this object,

70
00:02:47,290 --> 00:02:50,241
the different labels and their values,

71
00:02:50,241 --> 00:02:53,520
that make up, this overall object.

72
00:02:53,520 --> 00:02:57,640
And we call these label value combinations properties

73
00:02:57,640 --> 00:03:01,470
in the context of such a object in JavaScript.

74
00:03:01,470 --> 00:03:04,480
And these labels are up to us.

75
00:03:04,480 --> 00:03:08,030
And we could say that a job is described by a title

76
00:03:08,030 --> 00:03:09,860
and then maybe the place

77
00:03:09,860 --> 00:03:11,850
where this job is being done.

78
00:03:11,850 --> 00:03:14,630
And therefore we could add two labels here,

79
00:03:14,630 --> 00:03:16,210
a title label,

80
00:03:16,210 --> 00:03:18,610
and then separated by a comma,

81
00:03:18,610 --> 00:03:19,480
our

82
00:03:19,480 --> 00:03:20,313
place

83
00:03:20,313 --> 00:03:21,680
label.

84
00:03:21,680 --> 00:03:24,050
And again, these labels are up to you.

85
00:03:24,050 --> 00:03:25,973
You can use any labels you want.

86
00:03:27,266 --> 00:03:31,210
Now the labels on their own are not that useful though.

87
00:03:31,210 --> 00:03:33,370
If we have a look at our passport again,

88
00:03:33,370 --> 00:03:35,220
we did not just have the labels there,

89
00:03:35,220 --> 00:03:38,047
but also values for those labels

90
00:03:38,915 --> 00:03:41,490
and values are now assigned,

91
00:03:41,490 --> 00:03:43,167
not with an equal sign,

92
00:03:43,167 --> 00:03:47,160
but by a colon after our labels.

93
00:03:47,160 --> 00:03:49,280
And then after that colon,

94
00:03:49,280 --> 00:03:51,340
before you have that comma,

95
00:03:51,340 --> 00:03:53,050
and then the next label

96
00:03:53,050 --> 00:03:55,770
you have to value for that label

97
00:03:55,770 --> 00:03:59,350
and values for labels instead of an object.

98
00:03:59,350 --> 00:04:03,640
Can again be all those values you already learned about

99
00:04:03,640 --> 00:04:04,473
strings,

100
00:04:04,473 --> 00:04:05,306
numbers,

101
00:04:05,306 --> 00:04:06,760
arrays,

102
00:04:06,760 --> 00:04:08,310
even other objects.

103
00:04:08,310 --> 00:04:10,180
So-called nested objects,

104
00:04:10,180 --> 00:04:12,363
but that's something we'll explore later.

105
00:04:13,400 --> 00:04:14,233
So here,

106
00:04:14,233 --> 00:04:15,810
our title could be a string

107
00:04:15,810 --> 00:04:19,873
and that could be developer for example,

108
00:04:21,149 --> 00:04:24,710
and then place also needs a value.

109
00:04:24,710 --> 00:04:27,410
So we add a colon and then again,

110
00:04:27,410 --> 00:04:29,320
a value that makes sense here.

111
00:04:29,320 --> 00:04:31,380
So that could again be a string

112
00:04:31,380 --> 00:04:33,693
and it's maybe New York,

113
00:04:34,830 --> 00:04:37,200
maybe a job also has

114
00:04:37,200 --> 00:04:38,750
a Salary.

115
00:04:38,750 --> 00:04:40,730
And that could be a number let's say

116
00:04:40,730 --> 00:04:41,924
50,000

117
00:04:41,924 --> 00:04:43,990
U.S dollars per year

118
00:04:43,990 --> 00:04:46,473
or anything like that.

119
00:04:46,473 --> 00:04:48,740
That could be a job,

120
00:04:48,740 --> 00:04:52,310
a rich object where multiple pieces of data

121
00:04:52,310 --> 00:04:54,187
are grouped together.

122
00:04:54,187 --> 00:04:56,450
Now we could also use

123
00:04:56,450 --> 00:04:58,877
three individual variables.

124
00:04:58,877 --> 00:05:01,650
We could create a variable

125
00:05:01,650 --> 00:05:03,056
job

126
00:05:03,056 --> 00:05:04,400
title

127
00:05:04,400 --> 00:05:06,170
that store's developer

128
00:05:06,170 --> 00:05:08,220
and create another variable

129
00:05:08,220 --> 00:05:09,053
job

130
00:05:09,053 --> 00:05:09,886
place

131
00:05:09,886 --> 00:05:11,610
that store's New York,

132
00:05:11,610 --> 00:05:14,050
and create yet another variable

133
00:05:14,050 --> 00:05:14,883
job

134
00:05:14,883 --> 00:05:15,716
salary

135
00:05:15,716 --> 00:05:18,040
that store's the 50,000.

136
00:05:18,040 --> 00:05:20,876
We could use these three variables instead

137
00:05:20,876 --> 00:05:23,460
of this job object.

138
00:05:23,460 --> 00:05:26,240
We could work with a those of variables in our

139
00:05:26,240 --> 00:05:28,710
subsequent code as well,

140
00:05:28,710 --> 00:05:29,543
but

141
00:05:29,543 --> 00:05:32,090
if we use three individual variables,

142
00:05:32,090 --> 00:05:33,610
instead of one object,

143
00:05:33,610 --> 00:05:35,340
then we as a developer,

144
00:05:35,340 --> 00:05:37,910
always have to kind of keep in mind

145
00:05:37,910 --> 00:05:42,910
that these three variables are logically related.

146
00:05:43,120 --> 00:05:45,270
And that might be easy to do,

147
00:05:45,270 --> 00:05:48,330
especially in a simple script like this,

148
00:05:48,330 --> 00:05:51,000
but it's even easier if you grouped them together

149
00:05:51,000 --> 00:05:53,930
explicitly by creating such an object

150
00:05:53,930 --> 00:05:55,790
just as we created an array for

151
00:05:55,790 --> 00:05:58,130
multiple connected list items,

152
00:05:58,130 --> 00:06:01,720
instead of working with multiple variables.

153
00:06:01,720 --> 00:06:03,880
And that's why here I will not create

154
00:06:03,880 --> 00:06:05,733
three individual variables,

155
00:06:07,071 --> 00:06:08,727
but instead of one object that

156
00:06:08,727 --> 00:06:10,860
has these different properties,

157
00:06:10,860 --> 00:06:11,693
by the way,

158
00:06:11,693 --> 00:06:16,050
you can of course think about these properties as variables

159
00:06:16,050 --> 00:06:17,370
that are

160
00:06:17,370 --> 00:06:21,820
a scoped, that belong to one object.

161
00:06:21,820 --> 00:06:24,510
You don't have to let keyword here though.

162
00:06:24,510 --> 00:06:27,681
You just directly have to label name and then the value.

163
00:06:27,681 --> 00:06:30,170
And you assign that with a colon

164
00:06:30,170 --> 00:06:31,820
instead of an equal sign.

165
00:06:31,820 --> 00:06:32,670
But other than that,

166
00:06:32,670 --> 00:06:34,880
it's basically like variables

167
00:06:34,880 --> 00:06:36,050
that are

168
00:06:36,050 --> 00:06:37,300
closed

169
00:06:37,300 --> 00:06:38,810
into that object.

170
00:06:38,810 --> 00:06:39,803
So to say.

