JS Built-ins
FunctionalProgrammingintermediate

Cache miss still computes

πŸ“– Usage Example
const memo = memoize(fn);
memo(42); // miss β€” computed and cached
memo(99); // miss β€” computed and cached
memo(42); // hit β€” returned from cache

A cache miss means the input is new; the function runs and stores the result.

Cache Misses Trigger Computation

When an argument is not in the cache, the function must compute the result.

Challenge: Verify that calling a memoized function with new arguments computes results for cache misses.

πŸ’‘ Hints (3)
  • β€’ Cache miss occurs when x not in cache
  • β€’ Cache hit occurs when x already in cache
  • β€’ Only cache misses trigger function execution