A memoization helper puts results in a plain object using input objects as keys. Different input objects keep overwriting one another. When would you use a Map, and when would you prefer a stable ID as the key?
The plain object coerces the keys into property keys. Ordinary objects commonly produce the same string key. A Map can key directly by object identity, so separate objects stay separate even if their fields match. A stable ID is a better key when distinct objects represent the same entity, provided that the ID captures all inputs relevant to the cached result or the cache is invalidated appropriately.
What a Strong Answer Covers
Explain key coercion in a plain object.
Choose the key based on identity versus domain equivalence.
Follow-up Interview Question · What changes if the input object is mutated after its result is cached?