es6-arrow-functions Flashcards

1
Q

What is the syntax for defining an arrow function?

A

(parameters separated by commas) => {code block};
If there is only 1 parameter, the parentheses are not needed. If return is a simple expression, brackets and return keyword can be omitted (needed for multiline statements)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

When an arrow function’s body is left without curly braces, what changes in its functionality?

A

The body becomes a return statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How is the value of this determined within an arrow function?

A

An arrow function has lexical ‘this’; the value is determined by the surrounding scope (determined by the parent scope)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly