Closures Flashcards
1
Q
What must the return value of myFunction be if the following expression is possible?
myFunction( )( );
A
the return value of the return value
2
Q
In JavaScript, when is a function’s scope determined; when it is called or when it is defined?
A
when it is defined
3
Q
What allows JavaScript functions to “remember” values from their surroundings?
A
closures are created every time a function is created - they allow functions to maintain a reference to their lexical environment, containing any local variables that were in-scope at function creation time
4
Q
What does this code do? const wrap = value => ( ) => value;
A
defining an anonymous arrow function named wrap that takes one parameter (value) and returns an anonymous arrow function that returns value