Junior JavaScript

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));

More from JavaScript Tutorial

All questions for this course