Last active
September 28, 2020 02:15
-
-
Save rayinla/8b18387094f9438fa8200d8893cd3e2c 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 memo(func){ | |
| var cache = {}; | |
| return function(){ | |
| var key = JSON.stringify(arguments); | |
| if (cache[key]){ | |
| console.log(cache) | |
| return cache[key]; | |
| } | |
| else{ | |
| val = func.apply(null, arguments); | |
| cache[key] = val; | |
| return val; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment