Weak Areas Flashcards
(3 cards)
1
Q
What is a closure in JavaScript?
A
A closure is when a function remembers and can access variables from its outer scope even after that outer function has finished executing.
2
Q
What is memoization used for?
A
Memoization is used to speed up functions by caching the results of expensive function calls and returning the cached result when the same input occurs again.
3
Q
How does memoization typically use closures?
A
Memoization uses closures to maintain a private cache object that persists across calls to the memoized function.