Created
September 22, 2011 04:22
-
-
Save yuppism/1234027 to your computer and use it in GitHub Desktop.
clousureではまったときのサンプルコード
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 code2name = function(){ | |
var mapping = { | |
'us': 'United States', | |
'ja': 'Japan', | |
'ko': 'Korea', | |
'ru': 'Russa', | |
'uk': 'United Kingdom', | |
'fr': 'France', | |
'cc': 'China', | |
'gw': 'Germany' | |
}; | |
return function(code) { | |
return mapping[code] || '(unknown)'; | |
}; | |
}; | |
var method = code2name(); | |
method('ko'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment