memoization

Remembering the result of a calculation for given inputs and reusing it when the same inputs come again, instead of recalculating.

In more detail

It trades memory for speed and is only correct for pure calculations. Inputs are usually compared by identity to decide whether a stored result applies.

Example

React offers React.memo, useMemo and useCallback, and the React Compiler can add memoization automatically at build time.

Related terms

Taught in

References