JavaScript · Middle · Question 16 of 75
What is memoization?
- ✓Correct answer: Caching a function's results by arguments to avoid recomputing them
- 2Freeing memory from unused objects by the garbage collector
- 3Saving application state in
localStoragebetween sessions
Explanation
A memoized function keeps an "arguments → result" Map in a closure. It works for pure functions. Downsides are memory growth and the difficulty of keys for objects (WeakMap is often used).