What is memoization, and how can it be used in
ngular for performance improvement?
Memoization:
technique to cache the results of expensive function calls and return the cached result
when inputs are the same.
How it helps:
- Avoids recalculating heavy operations on every change detection.
- Improves performance for pure functions or selectors.
✅ Example in Angular:
const memoizedFunction = memoize((input) => {
// expensive calculation
return result;
});
this.result = memoizedFunction(input);
You can use libraries like lodash's _.memoize or write your own.
ngular Module System