Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement