Performance Optimization Techniques
What memory optimization pattern is shown here?
const cache = new WeakMap();
function getData(obj) {
if (cache.has(obj)) {
return cache.get(obj);
}
const data = computeExpensiveData(obj);
cache.set(obj, data);
return data;
}