Skip to content

Instantly share code, notes, and snippets.

@madrobby
Created July 30, 2010 16:13
Show Gist options
  • Save madrobby/500794 to your computer and use it in GitHub Desktop.
Save madrobby/500794 to your computer and use it in GitHub Desktop.
Function.prototype.cached = function(){
var self = this, cache = {};
return function(arg){
if(arg in cache) return cache[arg];
return cache[arg] = self(arg);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment