Deeping JS
JavaScript
/* let worker = {
someMethod() {
return 1;
},
slow(x) {
alert("Called with " + x);
return x * this.someMethod(); // (*)
}
}; */
function slow(x) {
console.log("slowed " + x)
}
function cacheIt(func) {
let cache = new Map();
return function (x) {
if (cache.has(x)) {
return cache.get(x);
}
let result=func(x);
cache.set(x),
}
}