Skip to content

Instantly share code, notes, and snippets.

@tkheyfets tkheyfets/memoize.js
Created Mar 18, 2016

What would you like to do?
function memoize(fn) {
var slice = Array.prototype.slice,
cache = [];
return function () {
var args =,
result = cache[args];
if (!result) {
result = cache[args] = fn.apply(this, args);
return result;
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.