Skip to content

Instantly share code, notes, and snippets.

@bjdixon bjdixon/memo.js
Last active Aug 29, 2015

What would you like to do?
Memoize a function
memo = function (fn) {
var cache = {};
return function () {
var key = JSON.stringify(this, arguments);
return cache[key] || (cache[key] = fn.apply(this, arguments));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.