Last active
March 20, 2019 06:50
-
-
Save Krasnov8953/662683fa1ab7976b23cad604edfc4c41 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function memoize(func) { | |
const memo = {}; | |
return function() { | |
const args = [...arguments]; | |
if (args in memo) { | |
return memo[args]; | |
} | |
else { | |
return (memo[args] = func.apply(this, args)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment