closures, recursion, axios Flashcards

1
Q

What must the return value ofmyFunctionbe if the following expression is possible ?myFunction()();

  • What does this code do? const wrap = value => () => value;
A
  • It would return the return of the function, which should be a function.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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 or lexical scope. It means it is determined where you wrote the code.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
  • What allows JavaScript functions to “remember” values from their surroundings?
A
  • Closures. It keeps variables in memory. Like a functions backpack, it remembers stuff from functions outer function.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a closure?

A

Aclosureis the combination of a function and the lexical environment within which that function was declared.

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

What are 4 JS fundamentals?

A

Closures, event loop, prototypal inheritance, this

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