1
00:00:02,130 --> 00:00:04,140
So first, a quick summary,

2
00:00:04,140 --> 00:00:06,880
what do we already know about functions?

3
00:00:06,930 --> 00:00:10,880
Functions are these constructs which allow us to define code on-demand

4
00:00:10,890 --> 00:00:17,520
and when Javascript reads our script, it basically goes through the entire script first, finds all

5
00:00:17,520 --> 00:00:23,880
these function declarations which we added, registers them and then it really starts executing the script

6
00:00:24,390 --> 00:00:26,820
and we can call our functions as often as we want,

7
00:00:26,820 --> 00:00:33,000
so we have code which we can execute multiple times from different places in our program.

8
00:00:33,000 --> 00:00:38,940
You also learned that if you create variables or constants inside of a function, they belong to that function

9
00:00:38,940 --> 00:00:46,470
because of that block scope thing covered in the last module. Functions can take parameters, also called

10
00:00:46,530 --> 00:00:52,770
arguments and can return a value, they have to do neither of that and they can take as any parameters

11
00:00:52,770 --> 00:00:58,080
if you want, if you need them but you can also write functions that neither take parameters nor return

12
00:00:58,080 --> 00:00:59,260
anything.

13
00:00:59,760 --> 00:01:05,460
As I mentioned, functions can be called multiple times and of course you typically would pass different

14
00:01:05,460 --> 00:01:09,090
values for these arguments then because that's the cool thing about a function,

15
00:01:09,180 --> 00:01:15,810
it's code on-demand and it is able to be dynamic because it can take arguments and the arguments can

16
00:01:15,810 --> 00:01:18,210
differ from function call to function call,

17
00:01:18,240 --> 00:01:23,910
so the same function will typically produce different results for different calls because of different

18
00:01:23,970 --> 00:01:30,840
arguments for example and you can also call functions kind of directly or indirectly, where directly

19
00:01:30,840 --> 00:01:37,290
was when you called a function by adding parentheses after to function name and indirectly was for example

20
00:01:37,290 --> 00:01:43,620
the case when you bound or when you attached a function to a button with the help of the add event

21
00:01:43,620 --> 00:01:45,690
listener call which you saw.

22
00:01:45,690 --> 00:01:47,570
So that's what we already know,

23
00:01:47,610 --> 00:01:50,460
now let's see what we can learn about functions.
