1
00:00:02,090 --> 00:00:04,370
Now that's it for functions.

2
00:00:04,370 --> 00:00:05,300
Now, I, again,

3
00:00:05,300 --> 00:00:08,290
wanna look behind the scenes of JavaScript,

4
00:00:08,290 --> 00:00:09,810
and specifically,

5
00:00:09,810 --> 00:00:14,810
I wanna explain why this kind of code worked.

6
00:00:16,329 --> 00:00:20,200
This is some code which we had in an earlier course section

7
00:00:20,200 --> 00:00:24,140
and there we have an array and we stored that array in a

8
00:00:24,140 --> 00:00:29,140
constant, and then I push a new value into that array.

9
00:00:30,730 --> 00:00:31,563
And hence,

10
00:00:31,563 --> 00:00:35,750
we clearly changed the array because we add a new value.

11
00:00:35,750 --> 00:00:38,780
Nonetheless, that code worked even though for a constant,

12
00:00:38,780 --> 00:00:41,020
you shouldn't be able to change

13
00:00:41,020 --> 00:00:43,293
the value stored in the constant.

14
00:00:44,520 --> 00:00:48,570
Now back then I explained that for arrays and also objects,

15
00:00:48,570 --> 00:00:51,830
that's kind of a special scenario and you can change

16
00:00:51,830 --> 00:00:53,690
the object and array itself.

17
00:00:53,690 --> 00:00:57,140
As long as you don't assign a new value to the constant

18
00:00:57,140 --> 00:00:59,283
itself with the equal sign.

19
00:01:00,320 --> 00:01:03,280
I now wanna explore this again and explain in greater

20
00:01:03,280 --> 00:01:06,330
detail why it works like this.

21
00:01:06,330 --> 00:01:08,480
And for this, I'll add a new file,

22
00:01:08,480 --> 00:01:09,313
which I will name

23
00:01:09,313 --> 00:01:12,143
behind-the-scenes.js,

24
00:01:13,143 --> 00:01:15,390
and in there, I'll again,

25
00:01:15,390 --> 00:01:18,900
add an array and it's an array of hobbies let's say.

26
00:01:18,900 --> 00:01:22,470
And in there I have sports and cooking.

27
00:01:22,470 --> 00:01:25,410
That's my array here.

28
00:01:25,410 --> 00:01:27,010
Now I'll do what I did before.

29
00:01:27,010 --> 00:01:31,360
And I'll push a new value into that array, for example,

30
00:01:31,360 --> 00:01:32,203
reading.

31
00:01:33,970 --> 00:01:38,860
And if we then console log, hobbies thereafter,

32
00:01:38,860 --> 00:01:43,250
you will see that if we run this behind the scenes JS file

33
00:01:43,250 --> 00:01:44,500
with node,

34
00:01:44,500 --> 00:01:48,520
we get this updated array and we don't get any error.

35
00:01:48,520 --> 00:01:50,530
Now that's what we saw before,

36
00:01:50,530 --> 00:01:53,170
but why exactly does this work?

37
00:01:53,170 --> 00:01:57,757
Why does const only care about whether we try to assign a

38
00:01:57,757 --> 00:02:00,700
new value with the equal sign,

39
00:02:00,700 --> 00:02:04,100
instead of just ensuring in general that the underlying

40
00:02:04,100 --> 00:02:05,573
value doesn't change?

41
00:02:06,810 --> 00:02:07,740
Well in the end,

42
00:02:07,740 --> 00:02:09,759
because that's how JavaScript works.

43
00:02:09,759 --> 00:02:11,560
But there also is a reason for that.

44
00:02:12,540 --> 00:02:14,770
Arrays and objects,

45
00:02:14,770 --> 00:02:16,730
and actually just like functions,

46
00:02:16,730 --> 00:02:19,350
arrays are objects under the hood,

47
00:02:19,350 --> 00:02:21,800
just special kinds of objects you could say.

48
00:02:21,800 --> 00:02:23,340
So therefore, objects,

49
00:02:23,340 --> 00:02:28,240
which include arrays are stored in a special kind of memory

50
00:02:28,240 --> 00:02:29,563
by JavaScript.

51
00:02:30,410 --> 00:02:32,740
Now we could dive super deep into that,

52
00:02:32,740 --> 00:02:34,920
but it doesn't matter too much right now.

53
00:02:34,920 --> 00:02:38,350
It's just important to keep in mind that objects

54
00:02:38,350 --> 00:02:40,640
and therefore all the arrays are stored

55
00:02:40,640 --> 00:02:42,960
in a special kind of memory.

56
00:02:42,960 --> 00:02:43,793
And for example,

57
00:02:43,793 --> 00:02:47,490
numbers or any other kind of value like strings or

58
00:02:47,490 --> 00:02:51,660
booleans are stored in a different kind of memory

59
00:02:51,660 --> 00:02:54,900
because numbers, strings and booleans,

60
00:02:54,900 --> 00:02:59,693
and a couple of other values are so-called primitive values.

61
00:03:01,250 --> 00:03:04,150
So we have our primitive values, which are numbers,

62
00:03:04,150 --> 00:03:09,150
strings and booleans and all couple of other values that

63
00:03:10,030 --> 00:03:13,770
don't matter too much right now, for example, undefined,

64
00:03:13,770 --> 00:03:17,373
which we saw before is also such a primitive value.

65
00:03:18,830 --> 00:03:22,500
And then we also have so-called the reference values,

66
00:03:22,500 --> 00:03:25,120
or reference value types,

67
00:03:25,120 --> 00:03:28,910
and that would be objects and since arrays and also

68
00:03:28,910 --> 00:03:31,110
functions are objects.

69
00:03:31,110 --> 00:03:36,110
Those values are also reference values and reference values

70
00:03:36,820 --> 00:03:40,150
are stored in a different kind of computer memory

71
00:03:40,150 --> 00:03:42,670
than primitive values are.

72
00:03:42,670 --> 00:03:44,680
The reason for that is simply that

73
00:03:44,680 --> 00:03:49,510
objects tend to be a bit more complex after all they can

74
00:03:49,510 --> 00:03:51,210
contain multiple values.

75
00:03:51,210 --> 00:03:54,973
Multiple key value pairs, maybe even some methods.

76
00:03:55,950 --> 00:03:59,140
The primitive values are really primitive.

77
00:03:59,140 --> 00:04:02,400
They are simple, it's a single number or a single string,

78
00:04:02,400 --> 00:04:06,190
even if it's a longer string, it's still pretty simple.

79
00:04:06,190 --> 00:04:09,830
And hence primitive values are stored in a more basic kind

80
00:04:09,830 --> 00:04:13,890
of computer memory. Objects are stored in a more advanced

81
00:04:13,890 --> 00:04:16,433
kind of computer memory. You could say.

82
00:04:17,790 --> 00:04:21,220
Now, because objects can and tend to be more

83
00:04:21,220 --> 00:04:22,590
complex.

84
00:04:22,590 --> 00:04:27,590
They are stored such that unnecessary copies of objects

85
00:04:28,490 --> 00:04:33,410
are avoided simply because a simple number doesn't take up a

86
00:04:33,410 --> 00:04:37,230
lot of space and memory, a complex object does.

87
00:04:37,230 --> 00:04:41,260
So we wanna avoid that we are unnecessarily copying

88
00:04:41,260 --> 00:04:42,653
objects around.

89
00:04:43,760 --> 00:04:44,593
Therefore,

90
00:04:44,593 --> 00:04:48,250
and that's now the part where this push thing combined with

91
00:04:48,250 --> 00:04:51,590
a constant will make more sense. Therefore,

92
00:04:51,590 --> 00:04:55,750
when you create an array or an object and you store it in a

93
00:04:55,750 --> 00:04:59,370
variable or a constant, what you actually stored

94
00:04:59,370 --> 00:05:04,310
there is not the value. So the object or array itself,

95
00:05:04,310 --> 00:05:09,310
but a pointer to that object or array in memory.

96
00:05:09,600 --> 00:05:14,440
So the address of that object in memory.

97
00:05:14,440 --> 00:05:16,500
You don't see that here in the code.

98
00:05:16,500 --> 00:05:19,330
It looks like the array itself is stored here,

99
00:05:19,330 --> 00:05:22,320
but that's actually not what happens. Instead.

100
00:05:22,320 --> 00:05:26,713
A pointer to the array is stored.

101
00:05:28,410 --> 00:05:31,680
If you store a number on the array or a string,

102
00:05:31,680 --> 00:05:36,680
the value itself is stored in the variable or a constant.

103
00:05:39,910 --> 00:05:41,940
Now, since that's the case,

104
00:05:41,940 --> 00:05:46,670
when you push a new value to that array,

105
00:05:46,670 --> 00:05:51,403
this value is added to the existing array in memory,

106
00:05:52,330 --> 00:05:56,610
but the pointer doesn't change, the address of that

107
00:05:56,610 --> 00:05:58,830
array in memory doesn't change.

108
00:05:58,830 --> 00:06:03,830
So the address of the array doesn't change,

109
00:06:04,770 --> 00:06:07,540
and that's why we can do that on a constant,

110
00:06:07,540 --> 00:06:09,960
because the constant stored the address,

111
00:06:09,960 --> 00:06:12,223
and the address didn't change.

112
00:06:13,290 --> 00:06:17,840
So when you call push to add a new value to an array,

113
00:06:17,840 --> 00:06:21,860
that actually tells JavaScript to look up that address,

114
00:06:21,860 --> 00:06:26,570
go to the actual array in memory and add that value there.

115
00:06:26,570 --> 00:06:30,930
The value stored in the constant did not change because that

116
00:06:30,930 --> 00:06:33,623
value is the address not the array itself.

117
00:06:34,900 --> 00:06:37,500
That's why you can do that. On the other hand,

118
00:06:37,500 --> 00:06:42,180
if you would try to set hobbies equal to a new array where

119
00:06:42,180 --> 00:06:46,180
you have coding and sleeping or something like that,

120
00:06:46,180 --> 00:06:49,200
that would not be allowed

121
00:06:49,200 --> 00:06:52,410
because here we create a new array,

122
00:06:52,410 --> 00:06:55,917
which receives its own new place in memory and which

123
00:06:55,917 --> 00:06:58,573
therefore receives and you address.

124
00:07:00,350 --> 00:07:03,360
And we would therefore try to store and you address and this

125
00:07:03,360 --> 00:07:04,193
constant,

126
00:07:04,193 --> 00:07:07,470
which is not allowed because it overrides the old value of

127
00:07:07,470 --> 00:07:10,023
the constant, which was the old address.

128
00:07:11,440 --> 00:07:15,953
So that's why we can push into an array that's stored

129
00:07:15,953 --> 00:07:18,620
in a constant because of that reference,

130
00:07:18,620 --> 00:07:21,053
whereas there's this primitive value thing.

131
00:07:22,240 --> 00:07:25,180
Now I do have a complete guide on JavaScript,

132
00:07:25,180 --> 00:07:27,680
which has 55 hours on its own,

133
00:07:27,680 --> 00:07:31,780
where I dive way deeper into JavaScript and where I also

134
00:07:31,780 --> 00:07:34,850
explain this concept in greater detail.

135
00:07:34,850 --> 00:07:37,200
We don't need all these details right now,

136
00:07:37,200 --> 00:07:40,590
but it's hopefully still clear that objects are simply

137
00:07:40,590 --> 00:07:42,860
stored differently in memories,

138
00:07:42,860 --> 00:07:45,850
than primitive values like numbers are

139
00:07:45,850 --> 00:07:47,320
and that because of that,

140
00:07:47,320 --> 00:07:50,800
and because we only store the address of the object in the

141
00:07:50,800 --> 00:07:53,410
constant, instead of the object itself,

142
00:07:53,410 --> 00:07:57,740
we can manipulate the underlying object or array without

143
00:07:57,740 --> 00:08:00,410
manipulating the constant value itself.

144
00:08:00,410 --> 00:08:04,050
Because the constant value is only that address.

145
00:08:04,050 --> 00:08:06,390
This primitive words reference value

146
00:08:06,390 --> 00:08:08,140
of thing also has a couple of important

147
00:08:08,140 --> 00:08:09,083
implications.

148
00:08:10,130 --> 00:08:14,310
Let's say we have an object now person,

149
00:08:14,310 --> 00:08:17,940
which has an age value of 32.

150
00:08:17,940 --> 00:08:20,110
Of course, that's a simple object.

151
00:08:20,110 --> 00:08:21,900
It's almost only a number,

152
00:08:21,900 --> 00:08:25,440
but still it is a object and we could have more properties

153
00:08:25,440 --> 00:08:26,590
and methods in there.

154
00:08:26,590 --> 00:08:29,203
I'm just trying to keep this simple here.

155
00:08:30,060 --> 00:08:32,679
So let's say we have this person object with potentially

156
00:08:32,679 --> 00:08:37,500
more properties, and then we have a function, not a method,

157
00:08:37,500 --> 00:08:39,409
but a standalone function here,

158
00:08:39,409 --> 00:08:42,380
which maybe gives us the number of adult years.

159
00:08:42,380 --> 00:08:46,150
This person has. So I'll name us get adult years.

160
00:08:46,150 --> 00:08:50,330
And I get a person here as a parameter,

161
00:08:50,330 --> 00:08:54,700
or let's just name it P here to avoid any confusion with the

162
00:08:54,700 --> 00:08:56,373
same name being used.

163
00:08:57,400 --> 00:09:02,400
And what I do in here is I want to get my adult years

164
00:09:04,290 --> 00:09:07,380
by setting p.age,

165
00:09:07,380 --> 00:09:09,380
because I expect P to be an object

166
00:09:09,380 --> 00:09:10,473
of that shape,

167
00:09:11,410 --> 00:09:14,983
equal to p.age minus 18.

168
00:09:16,000 --> 00:09:16,833
And hence,

169
00:09:16,833 --> 00:09:20,800
we can also use this shortcut and write it like this.

170
00:09:20,800 --> 00:09:24,690
And then I return P age,

171
00:09:24,690 --> 00:09:28,340
which is now just a number of years above 18.

172
00:09:28,340 --> 00:09:31,233
Since we deduct 18 from that age,

173
00:09:32,620 --> 00:09:37,620
if we now console log get adult years and we pass the person

174
00:09:39,110 --> 00:09:42,080
object that we created here into that,

175
00:09:42,080 --> 00:09:44,563
we should get 14 as a result.

176
00:09:46,010 --> 00:09:50,520
So if we now execute this file, indeed I do get 14 here,

177
00:09:50,520 --> 00:09:53,433
but we have a side effect here.

178
00:09:54,580 --> 00:09:59,160
Watch what happens if I also console log person after

179
00:09:59,160 --> 00:10:00,993
calling get adult years.

180
00:10:02,230 --> 00:10:05,490
If I now execute that file, we get 14 as before.

181
00:10:05,490 --> 00:10:09,160
But when I output the person here,

182
00:10:09,160 --> 00:10:14,160
I get age set equal to 14. And you might say sure,

183
00:10:14,440 --> 00:10:17,390
because that's what we did here. But on the other hand,

184
00:10:17,390 --> 00:10:21,990
we did that on the person we received as a parameter inside

185
00:10:21,990 --> 00:10:25,260
of the function, not on this person,

186
00:10:25,260 --> 00:10:29,090
this person should still have age of 32 because it's that

187
00:10:29,090 --> 00:10:31,140
person, which I'm outputting here.

188
00:10:31,140 --> 00:10:33,820
It's only the parameter value which we had inside of the

189
00:10:33,820 --> 00:10:35,650
function that changed.

190
00:10:35,650 --> 00:10:39,730
But why did this now also affect this person?

191
00:10:39,730 --> 00:10:43,393
Because objects are reference values.

192
00:10:44,240 --> 00:10:45,350
Keep in mind,

193
00:10:45,350 --> 00:10:49,410
what's stored in person in this constant here is just the

194
00:10:49,410 --> 00:10:54,020
address of that object just as we simply stored the address

195
00:10:54,020 --> 00:10:56,073
of this array and hobbies before.

196
00:10:57,230 --> 00:10:58,790
Now, since that's the case,

197
00:10:58,790 --> 00:11:02,300
what we actually pass to get adult years when we call it

198
00:11:02,300 --> 00:11:05,430
with person is the address.

199
00:11:05,430 --> 00:11:10,000
So P instead of get adult years is just the address of the

200
00:11:10,000 --> 00:11:11,570
object.

201
00:11:11,570 --> 00:11:13,760
Now, when we use the dot notation here, we can,

202
00:11:13,760 --> 00:11:14,760
of course do that.

203
00:11:14,760 --> 00:11:19,180
And JavaScript will look up the object for that address for

204
00:11:19,180 --> 00:11:22,940
us then, and give us the age property off that object.

205
00:11:22,940 --> 00:11:27,550
But when I then changed his age off this object by deducting

206
00:11:27,550 --> 00:11:29,090
18 from it,

207
00:11:29,090 --> 00:11:33,040
I do not just change the person object in this function,

208
00:11:33,040 --> 00:11:35,460
but this person object as well,

209
00:11:35,460 --> 00:11:37,500
because it's the same object.

210
00:11:37,500 --> 00:11:40,900
There is only one object because we're just working with the

211
00:11:40,900 --> 00:11:42,360
address here.

212
00:11:42,360 --> 00:11:45,460
I get the address of this person when I called get adult

213
00:11:45,460 --> 00:11:46,293
years,

214
00:11:46,293 --> 00:11:49,960
hence I'm operating on the exact person object in memory

215
00:11:49,960 --> 00:11:52,043
when I deduct 18 year.

216
00:11:53,050 --> 00:11:55,870
And that's why when I console log person there,

217
00:11:55,870 --> 00:11:59,910
after we have the updated age here in the terminal,

218
00:11:59,910 --> 00:12:02,720
because it's one and the same object,

219
00:12:02,720 --> 00:12:07,020
and that's not a bug or an unintended side effect,

220
00:12:07,020 --> 00:12:11,400
but instead that's a behavior, which we have on purpose,

221
00:12:11,400 --> 00:12:12,770
because as mentioned,

222
00:12:12,770 --> 00:12:17,160
objects can become very complex and therefore they are

223
00:12:17,160 --> 00:12:22,160
managed such that unnecessary copies are avoided.

224
00:12:22,170 --> 00:12:23,003
Hence,

225
00:12:23,003 --> 00:12:27,010
the address is pass around instead of new copies of that

226
00:12:27,010 --> 00:12:28,330
object,

227
00:12:28,330 --> 00:12:32,400
therefore operations like this can have the unintended side

228
00:12:32,400 --> 00:12:36,420
effect of changing the original object in places where we

229
00:12:36,420 --> 00:12:38,033
don't wanna do that.

230
00:12:39,310 --> 00:12:43,163
Now, how can we avoid this unintended side effect here then?

231
00:12:44,010 --> 00:12:44,843
Well,

232
00:12:44,843 --> 00:12:49,120
one work around would be that we don't update

233
00:12:49,120 --> 00:12:51,410
the person age here, but instead,

234
00:12:51,410 --> 00:12:54,430
if we just want to derive the adult years,

235
00:12:54,430 --> 00:12:56,780
instead of doing it like this,

236
00:12:56,780 --> 00:13:00,243
we can return p.age minus 18.

237
00:13:01,730 --> 00:13:06,310
It's minus 18, not minus equal. With this line of code,

238
00:13:06,310 --> 00:13:10,900
we are not setting a new value for person age. Instead,

239
00:13:10,900 --> 00:13:15,290
we are just arriving a value based on the existing age value

240
00:13:15,290 --> 00:13:16,820
minus 18,

241
00:13:16,820 --> 00:13:21,050
but that derived value does not override the age in person,

242
00:13:21,050 --> 00:13:24,900
but instead is simply returned as a value by get adult

243
00:13:24,900 --> 00:13:25,733
years.

244
00:13:27,220 --> 00:13:32,220
If we do that and we execute this file, we now have 14 here,

245
00:13:32,550 --> 00:13:36,090
but we didn't change the original object.

246
00:13:36,090 --> 00:13:38,580
That would be a better way of doing it.

247
00:13:38,580 --> 00:13:41,900
If you have a function that for some reason needs to

248
00:13:41,900 --> 00:13:44,860
manipulate the object itself, though.

249
00:13:44,860 --> 00:13:48,020
So let's say we wanna go back to that original code.

250
00:13:48,020 --> 00:13:52,460
Then you can still work around changing the original object

251
00:13:52,460 --> 00:13:57,433
by passing in a copy of person into get adult years.

252
00:13:58,420 --> 00:13:59,253
And to do that.

253
00:13:59,253 --> 00:14:02,260
You just need to create a new object by again,

254
00:14:02,260 --> 00:14:04,610
using the curly braces here,

255
00:14:04,610 --> 00:14:09,260
where you either add all the properties manually.

256
00:14:09,260 --> 00:14:11,980
So where you add an age property and set this equal to

257
00:14:11,980 --> 00:14:14,830
person dot age with that,

258
00:14:14,830 --> 00:14:17,600
we are creating a brand new object,

259
00:14:17,600 --> 00:14:21,180
a brand new place in memory with a brand new separate

260
00:14:21,180 --> 00:14:22,250
address.

261
00:14:22,250 --> 00:14:26,270
And we just populate age based on the values stored in

262
00:14:26,270 --> 00:14:30,140
persons age. But that is then a number which we use here.

263
00:14:30,140 --> 00:14:30,973
So with that,

264
00:14:30,973 --> 00:14:33,190
we're not pointing at the old person object

265
00:14:33,190 --> 00:14:35,820
as a whole in this place.

266
00:14:35,820 --> 00:14:40,600
And therefore, if we now would save that and run this code,

267
00:14:40,600 --> 00:14:42,260
it would work without issues.

268
00:14:42,260 --> 00:14:44,903
And the original object wasn't changed,

269
00:14:46,640 --> 00:14:49,070
but creating objects like this,

270
00:14:49,070 --> 00:14:52,080
and manually adding all the properties

271
00:14:52,080 --> 00:14:56,240
which the original object has into this new object can be

272
00:14:56,240 --> 00:14:57,433
very cumbersome.

273
00:14:58,540 --> 00:15:01,730
That's why we can use another operator here,

274
00:15:01,730 --> 00:15:06,730
which we already saw before. Between those curly braces,

275
00:15:07,020 --> 00:15:11,820
we can use the free dot operator, the spread operator,

276
00:15:11,820 --> 00:15:15,903
and spread our person object into this new object.

277
00:15:17,210 --> 00:15:18,043
Now,

278
00:15:18,043 --> 00:15:22,020
we haven't seen this usage of the spread operator before,

279
00:15:22,020 --> 00:15:26,060
but the spread operator can indeed be used on arrays

280
00:15:26,060 --> 00:15:29,660
or on objects and on arrays.

281
00:15:29,660 --> 00:15:34,660
As you saw before. It pulls out all the individual values to

282
00:15:35,260 --> 00:15:37,223
create a list of values.

283
00:15:38,080 --> 00:15:39,830
When used on objects,

284
00:15:39,830 --> 00:15:44,730
it pulls out all the key value pairs off the object and

285
00:15:44,730 --> 00:15:47,950
gives you a list of those key value pairs.

286
00:15:47,950 --> 00:15:50,550
And if you do that between curly braces,

287
00:15:50,550 --> 00:15:52,670
you create a new object,

288
00:15:52,670 --> 00:15:56,870
which gets a list of all the key value pairs of another

289
00:15:56,870 --> 00:15:57,820
object.

290
00:15:57,820 --> 00:16:01,850
And hence you get a new object in memory with a new address

291
00:16:01,850 --> 00:16:05,733
with all the old key value pairs of another object.

292
00:16:06,630 --> 00:16:11,280
That's a way of copying an object, of creating a brand new

293
00:16:11,280 --> 00:16:12,830
object of the same shape

294
00:16:12,830 --> 00:16:15,460
in a new place in memory and therefore that's

295
00:16:15,460 --> 00:16:20,260
another way of working around that issue in quotes,

296
00:16:20,260 --> 00:16:22,180
because it's not really an issue.

297
00:16:22,180 --> 00:16:24,540
It's an intended feature

298
00:16:24,540 --> 00:16:28,670
of having reference values for objects.

299
00:16:28,670 --> 00:16:31,860
If we now execute this file here again,

300
00:16:31,860 --> 00:16:35,960
we have the unchanged original object whilst also getting

301
00:16:35,960 --> 00:16:37,623
the correct adult years.

302
00:16:38,480 --> 00:16:42,250
With that code that changes the object.

303
00:16:42,250 --> 00:16:45,930
It does not change the original object anymore because we

304
00:16:45,930 --> 00:16:50,930
create a brand new object based on the original object here

305
00:16:51,000 --> 00:16:52,913
in this line, 21 now.

306
00:16:53,910 --> 00:16:54,743
And again,

307
00:16:54,743 --> 00:16:58,860
that is certainly a bit more advanced and can be challenging

308
00:16:58,860 --> 00:17:02,340
to grasp or to see why that's helpful.

309
00:17:02,340 --> 00:17:05,960
But we are going to write more and more advanced code over

310
00:17:05,960 --> 00:17:09,619
the next sections. And as a web developer in general,

311
00:17:09,619 --> 00:17:13,000
you will be confronted with more advanced code like this,

312
00:17:13,000 --> 00:17:16,390
and therefore you should be aware of this primitive versus

313
00:17:16,390 --> 00:17:18,260
reference value thing.

314
00:17:18,260 --> 00:17:22,380
And you also should know how you can create copies and work

315
00:17:22,380 --> 00:17:25,790
around that reference value limitation,

316
00:17:25,790 --> 00:17:28,130
which is sometimes face to avoid

317
00:17:28,130 --> 00:17:31,450
unintended side effects as we had them at the

318
00:17:31,450 --> 00:17:35,440
beginning, when we changed the original object,

319
00:17:35,440 --> 00:17:36,760
because you very often

320
00:17:36,760 --> 00:17:39,013
wanna avoid doing something like that.

