Skip to content

Instantly share code, notes, and snippets.

@Shinpeim
Created February 28, 2015 19:06
Show Gist options
  • Save Shinpeim/cfa72344c6da95f63932 to your computer and use it in GitHub Desktop.
Save Shinpeim/cfa72344c6da95f63932 to your computer and use it in GitHub Desktop.
// 連想配列,またはMap,またはDictionaryと呼ばれるもの
// JavaSctiptではこれをObjectと呼んでいる。
// Dictionaryの名の通り、「ある値」でそれを引くと
// それに対応する値を得ることができる。
var digits = {
"zero": 0,
"one": 1,
"two": 2,
"three": 3,
"four": 4,
"five": 5,
"six": 6,
"seven": 7,
"eight": 8,
"nine": 9
};
// "zero"でdigitsを引くと0が手に入る
console.log(digits["zero"]); //0
// "one"でdigitsを引くと1が手に入る
console.log(digits["one"]); //1
// "two"でdigitsを引くと2が手に入る
console.log(digits["two"]); //2
//...以下同じく続く
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment