What is memoization?
An optimization technique to cache function results for repeated inputs.
Example:
function memoize(fn) {
const cache = {};
return x => cache[x] || (cache[x] = fn(x));
An optimization technique to cache function results for repeated inputs.
Example:
function memoize(fn) {
const cache = {};
return x => cache[x] || (cache[x] = fn(x));