Created
August 28, 2013 05:46
-
-
Save shoyan/6362503 to your computer and use it in GitHub Desktop.
シンプルなキャッシュの例
This file contains 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
var list = function(val) { | |
if(!list.cache.hasOwnProperty(val)) { | |
list.cache[val] = val; | |
} | |
return list.cache[val]; | |
} | |
list.cache = {}; | |
list("foo"); | |
list.cache["foo"] == "foo"; | |
list("var"); | |
list.cache["var"] == "var"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment