Memoization is an optimization technique used to store the results of expensive function calls and return the cached result when the same inputs occur again. It can greatly improve the performance of functions that are repeatedly called with the same arguments.
We have a recursive function that calculates the nth Fibonacci number. How would you add memoisation in JavaScript to make it run faster?
If you call a memoised function twice with the same arguments, what does it return and why?
What could happen to memory usage if a memoised cache never gets cleared in a single‑page app?
You memoised a data‑fetching helper that caches results by query parameters. After release, some users see stale data when the backend updates. Why might that happen and how would you fix it?
A teammate says memoising a pure utility function caused a memory leak in a long‑running Node service. How would you investigate and resolve the issue?
What are the trade‑offs between using a plain object versus a WeakMap for memoisation inside a React component?
Design a memoisation layer for a high‑traffic API gateway that must cache expensive calculation results across multiple instances. What consistency, eviction, and scaling concerns would you address?
Our microservice memoises functions that depend on user‑specific context. How do you prevent the cache from leaking across users while still getting reuse benefits?
If we need to invalidate memoised results based on external events like a config change, what pattern would you implement in JavaScript to propagate invalidation safely?
We are moving a legacy monolith that heavily relies on in‑process memoisation to a serverless architecture. How would you refactor or replace that approach so it works across stateless Lambda invocations?
Several teams use memoisation inconsistently, leading to hidden bugs and performance regressions. As a staff engineer, how would you establish guidelines, tooling, and monitoring to manage memoisation organization‑wide?
When deciding between client‑side memoisation, edge CDN caching, and server‑side caching, what factors guide your choice and how would you communicate the trade‑offs to product and ops?