1
00:00:01,395 --> 00:00:04,061
What exactly is an arrow function, and how

2
00:00:04,061 --> 00:00:06,395
do we write them? They are anonymous

3
00:00:06,395 --> 00:00:08,595
functions with their own unique syntax. In

4
00:00:08,595 --> 00:00:10,195
this module, we will go through a few

5
00:00:10,195 --> 00:00:12,645
examples to illustrate not only how to

6
00:00:12,645 --> 00:00:15,645
write them, but also how they differ from

7
00:00:15,645 --> 00:00:17,895
regular functions. Arrow functions were

8
00:00:17,895 --> 00:00:20,395
introduced in ES6 version of JavaScript.

9
00:00:20,395 --> 00:00:22,172
If you come from a Java or Python

10
00:00:22,172 --> 00:00:25,395
background, you may also know them as

11
00:00:25,395 --> 00:00:27,895
lambda expressions. They greatly simplify

12
00:00:27,895 --> 00:00:29,728
creating function expressions. This will

13
00:00:29,728 --> 00:00:31,538
become a lot clearer when we rewrite some

14
00:00:31,538 --> 00:00:34,680
of the examples from our previous module

15
00:00:34,680 --> 00:00:37,395
using arrow functions. So why would you

16
00:00:37,395 --> 00:00:39,506
want to use them? Well, not only do they

17
00:00:39,506 --> 00:00:41,520
make our code concise and more readable

18
00:00:41,520 --> 00:00:43,895
because of the shorter syntax, but it's

19
00:00:43,895 --> 00:00:45,728
also a lot easier to understand how

20
00:00:45,728 --> 00:00:47,680
variables are scoped within them. Again,

21
00:00:47,680 --> 00:00:50,595
we'll go through a few examples to really

22
00:00:50,595 --> 00:00:53,284
illustrate this point. One thing to note

23
00:00:53,284 --> 00:00:55,145
here is that arrow functions are not

24
00:00:55,145 --> 00:00:57,395
really a substitute for regular functions.

25
00:00:57,395 --> 00:01:00,395
When you use arrow functions, you have to

26
00:01:00,395 --> 00:01:02,395
be aware of several side effects,

27
00:01:02,395 --> 00:01:04,109
especially around how the this keyword

28
00:01:04,109 --> 00:01:05,395
behaves, as well as how they don't have

29
00:01:05,395 --> 00:01:08,770
their own implicit arguments object. So,

30
00:01:08,770 --> 00:01:14,000
we can't really reference the arguments object the way we did in the last module.

