Skip to content

Instantly share code, notes, and snippets.

View alanjohnson's full-sized avatar
💭
Doing the things!

Alan Johnson alanjohnson

💭
Doing the things!
View GitHub Profile
@alanjohnson
alanjohnson / memoize
Created April 22, 2019 01:02
memoize function
function memoize(fn) {
const cache = {};
return function(...args) {
if ( cache[args] ) {
return cache[args];
};
const result = fn.apply(this, args);
cache[args] = result;
return result;
}