Created
November 7, 2017 18:21
-
-
Save Dammic/814657f3ebe956d30d9e081a31001e0b to your computer and use it in GitHub Desktop.
memoize
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 memoized(number) { | |
if (number === memoized.prototype.previousNumber) { | |
return memoized.prototype.previousValue; | |
} | |
memoized.prototype.previousNumber = number; | |
memoized.prototype.previousValue = { value: number }; | |
return memoized.prototype.previousValue; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment