es6-arrow-functions Flashcards

1
Q

What is the syntax for defining an arrow function?

A

let func = () => expression or {statement} with func being the name of the arrow function, expression being anything that returns a value and the statement being for functions that don’t need to return values

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 expression that is showing is automatically returned, it functions the same as let func = () => {return expression} but it is shorthand: let func = () => expression

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

The value of this is the value of this of the containing code block

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

When is the value of this determined for arrow functions?

A

The value of this is determined at definition time since it looks out to the containing code block to get its this value

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