Skip to content

Instantly share code, notes, and snippets.

@yairEO
Created April 21, 2019 11:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yairEO/d112b09a973b12cbfef72bd71b41dfa1 to your computer and use it in GitHub Desktop.
Save yairEO/d112b09a973b12cbfef72bd71b41dfa1 to your computer and use it in GitHub Desktop.
simple memoize
var foo = (memo => ()=> {
// if the function was already computed, return the computed value
if(memo) return memo;
// continue with regular logic and set "memo" to the output value for later calls
memo = 1;
return memo;
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment