Skip to content

Instantly share code, notes, and snippets.

@rayinla
Last active September 28, 2020 02:15
Show Gist options
  • Select an option

  • Save rayinla/8b18387094f9438fa8200d8893cd3e2c to your computer and use it in GitHub Desktop.

Select an option

Save rayinla/8b18387094f9438fa8200d8893cd3e2c to your computer and use it in GitHub Desktop.
function memo(func){
var cache = {};
return function(){
var key = JSON.stringify(arguments);
if (cache[key]){
console.log(cache)
return cache[key];
}
else{
val = func.apply(null, arguments);
cache[key] = val;
return val;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment