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lx;Hҷ݂[ű$HH풄&N%$	iK#yzmܤ8a^mY8=vH,I+%'r8U~]Pxx	[+G0%<8?Q#y}IG8HDŃ>6DWɿDof2i_)8LЁj|vڃEĢ_WYj\%,s7i(r:f$̐zxY"o qEU˿Ql:Ȝm3絠rJꋙhKtΚӎ[TֲrX[Rz~nB?Bh0'
Ned*{4^bh`plZO ,nmk>FM֩GO4l阒8WfnLz6ՊgQgN%u(FFb۷ԶFԩu!,3/<ܫ "Ϗ}|N&Y/z	qӬ9d؉,ܩZ@5е쨢"Jw	) Ƶ	Gp?Q6l2#E>۫ZQMFnbCdl;gV8)Y<А7Ήpd:7S<<QY4R񎭣ZՉu[G
>IjO8n-$w͹bTj܍ڧOi1_=% v%4^i|hWǖ܉3LihA4ҵKlwڐhށƌox7L֚5Al}mVDBkSdSSS3[IXoQLk2хñC²Pu
3Io=*4n^Hoj6P76,,y"s_B6Fkenl}Y|FPOLT/խ+mdn$?'r_H`$O6{̻4ؠb&4ːI?!_M?SD0(KY%@*ulZsj9~<ή=hH0v~ 	7fȗ1U?
Sʣwʇqd<X/X-ќxEĤZyzS_Ì=-/	A1My쁨rǑgܥ*\Jc75&lLߥU^d#X PX`{ڌbC rbTCO6B "ƸSa3Ȑ>cnB*'. (StSշ]E/LmOqnFVm@:g
WTI&;:VjJ|}o#,baCXcCXp{0℔^(\}JU/106
00:05:46,710 --> 00:05:48,770
and let's use 1991 again

107
00:05:49,790 --> 00:05:54,230
and then let's grab this console.log here

108
00:05:54,230 --> 00:05:58,383
and log both the ages, So age2 here,

109
00:05:59,650 --> 00:06:01,653
let's also add some comments here,

110
00:06:03,350 --> 00:06:08,350
function declaration and function expression.

111
00:06:13,200 --> 00:06:15,730
And so we should get twice

112
00:06:15,730 --> 00:06:19,800
the 46 value here and yes, indeed.

113
00:06:19,800 --> 00:06:22,320
So the functional expression works

114
00:06:22,320 --> 00:06:25,120
the exact same way as the function declaration.

115
00:06:25,120 --> 00:06:27,500
So we call it in the same way we capture

116
00:06:27,500 --> 00:06:29,700
the return value in the same way

117
00:06:29,700 --> 00:06:32,890
and then of course the result is also the same

118
00:06:32,890 --> 00:06:36,020
because the function body is the same.

119
00:06:36,020 --> 00:06:37,480
But it's very important to know

120
00:06:37,480 --> 00:06:41,020
that we have these two type of functions in JavaScript.

121
00:06:41,020 --> 00:06:43,580
Because in some places we will actually need

122
00:06:43,580 --> 00:06:45,540
to write them like this,

123
00:06:45,540 --> 00:06:48,740
as you will see as we go through the course.

124
00:06:48,740 --> 00:06:51,610
So again, this part here that I just highlighted

125
00:06:51,610 --> 00:06:54,970
this function here is in fact an expression

126
00:06:54,970 --> 00:06:58,440
and remember that expressions produce values.

127
00:06:58,440 --> 00:07:01,200
And so we just assign this whole value here

128
00:07:01,200 --> 00:07:04,100
then to this variable.

129
00:07:04,100 --> 00:07:06,480
And so this variable will then hold

130
00:07:06,480 --> 00:07:09,020
this function value basically.

131
00:07:09,020 --> 00:07:12,320
And one big implication of what I just said,

132
00:07:12,320 --> 00:07:15,310
So, that this here is just a value, yeah,

133
00:07:15,310 --> 00:07:17,420
is that in fact in JavaScript,

134
00:07:17,420 --> 00:07:20,050
functions are actually just values.

135
00:07:20,050 --> 00:07:24,290
So just as a number or a string or a boolean value.

136
00:07:24,290 --> 00:07:26,190
So a function is not a type, okay?

137
00:07:26,190 --> 00:07:28,800
It's not like a string or number type

138
00:07:28,800 --> 00:07:31,090
but it's also a value.

139
00:07:31,090 --> 00:07:34,670
And so if it's a value, we can store it in a variable.

140
00:07:34,670 --> 00:07:36,160
So just keep this in mind

141
00:07:36,160 --> 00:07:38,870
because it will become very important later

142
00:07:38,870 --> 00:07:42,400
when we really dig deep into functions.

143
00:07:42,400 --> 00:07:45,350
Now, besides these technical differences,

144
00:07:45,350 --> 00:07:48,100
you might be wondering what is the big deal?

145
00:07:48,100 --> 00:07:49,860
So what's the big difference between

146
00:07:49,860 --> 00:07:53,480
function declarations and function expressions?

147
00:07:53,480 --> 00:07:55,640
Well, the main practical difference

148
00:07:55,640 --> 00:07:58,600
is that we can actually call function declarations

149
00:07:58,600 --> 00:08:01,660
before they are defined in the code.

150
00:08:01,660 --> 00:08:05,130
So let me show that to you.

151
00:08:05,130 --> 00:08:07,720
So here is the declaration, right?

152
00:08:07,720 --> 00:08:10,700
This is the function declaration and as I just said,

153
00:08:10,700 --> 00:08:15,700
we can call them in a code before they are defined.

154
00:08:16,780 --> 00:08:21,260
So now we're calling it first and then defining it later.

155
00:08:21,260 --> 00:08:23,260
So let me show you that that still works

156
00:08:24,760 --> 00:08:27,390
and indeed we still get the same result.

157
00:08:27,390 --> 00:08:30,353
But if we attempt to do the same with the expression,

158
00:08:32,460 --> 00:08:34,650
then that should not work.

159
00:08:34,650 --> 00:08:38,570
So let's see and yeah,

160
00:08:38,570 --> 00:08:42,962
so cannot access calcAge2 before initialization, okay?

161
00:08:44,580 --> 00:08:46,790
and internally this happens

162
00:08:46,790 --> 00:08:49,800
because of a process called hoisting

163
00:08:49,800 --> 00:08:54,520
but more about that in a future section, okay?

164
00:08:54,520 --> 00:08:58,620
For now just keep in mind that you can call

165
00:08:58,620 --> 00:09:01,670
a function declaration before you define it

166
00:09:01,670 --> 00:09:06,670
even though that might not be such a good idea in many cases

167
00:09:06,810 --> 00:09:09,850
but you can do it if necessary.

168
00:09:09,850 --> 00:09:11,840
All right, now another question

169
00:09:11,840 --> 00:09:13,580
that you might have in your mind

170
00:09:13,580 --> 00:09:17,030
is which of the two types of functions should I use

171
00:09:17,030 --> 00:09:19,860
when I write my own functions?

172
00:09:19,860 --> 00:09:23,420
And well, the answer is that oftentimes

173
00:09:23,420 --> 00:09:27,070
it's really just a matter of personal preference.

174
00:09:27,070 --> 00:09:30,680
and so different developers prefer different formats.

175
00:09:30,680 --> 00:09:34,470
Personally, I prefer to use function expressions

176
00:09:34,470 --> 00:09:37,980
because this then forces me into a nice structure

177
00:09:37,980 --> 00:09:40,630
where I have to define all the functions first

178
00:09:40,630 --> 00:09:44,190
at the top of the code and only then I can call them.

179
00:09:44,190 --> 00:09:46,590
So this makes the code a little bit nicer

180
00:09:46,590 --> 00:09:48,330
and more structured.

181
00:09:48,330 --> 00:09:52,040
I also like to have everything stored in variables,

182
00:09:52,040 --> 00:09:55,640
so both values and functions, but again,

183
00:09:55,640 --> 00:09:58,520
that is just my own personal preference.

184
00:09:58,520 --> 00:10:01,580
And many other developers don't agree with this

185
00:10:01,580 --> 00:10:04,400
and prefer to use function declarations.

186
00:10:04,400 --> 00:10:08,470
So, if you also prefer a function declarations, that's fine.

187
00:10:08,470 --> 00:10:11,030
So, just use declarations then.

188
00:10:11,030 --> 00:10:13,030
It's absolutely no problem.

189
00:10:13,030 --> 00:10:16,570
However, even if you prefer one over the other,

190
00:10:16,570 --> 00:10:18,840
you still need to know about both

191
00:10:18,840 --> 00:10:22,360
the function expressions and function declarations.

192
00:10:22,360 --> 00:10:24,030
So you can not just pick one

193
00:10:24,030 --> 00:10:26,000
and then forget the other one

194
00:10:26,000 --> 00:10:29,140
because both have their place in JavaScript.

195
00:10:29,140 --> 00:10:31,370
And so it's really important that you know

196
00:10:31,370 --> 00:10:33,780
how to use and how's to distinguish

197
00:10:33,780 --> 00:10:36,913
both function declarations and expressions.

