var variable = 67;
var map =
{
key 1 : 'string_val',
key 2 : variable,
'key 3': function(){alert('blah')},
'if the key is not a valid variable name, or is reserved, quote it': true
}
alert(map.key 1);
alert(map['key 2']);
map.key 3();
if( map['if the key is not a valid variable name, or is reserved, quote it'])
alert('OK?');
(转)javascript 如何实现键值对
最新推荐文章于 2024-03-06 14:57:07 发布