memo.xight.org

日々のメモ

JavaScript で連想配列

var hash = new Array();
hash['year']  = 2005;
hash['month'] = 12;
hash['date']  = 14;

var str = '';
for ( key in hash ){
	str += key + ":" + hash[key] + "\n";
}
alert(str);


追記

JavaScriptはObjectで連想配列を利用可能.
var hash = new Object();

Reference

にっき - 2005-12-15
http://bigfield.ddo.jp/diary/20051215.html#p03