es6-arrow-functions Flashcards
1
Q
What is the syntax for defining an arrow function?
A
argument => return statement (w/o word ‘return’)
argument => { if multiple lines then include curly braces
and include return statement }
(arg1, arg2) => return statement (w/o word ‘return’)
( ) => return statement(w/o word return)
2
Q
When an arrow function’s body is left without curly braces, what changes in its functionality?
A
nothing, unless trying to return an object literal that also uses braces, so wrap them in parenthesis
3
Q
How is the value of this determined within an arrow function?
A
An arrow function doesn’t have its own this value. Instead, it uses the this value of the enclosing lexical scope