日期:2014-05-16 浏览次数:20382 次
<script> var map = {}; map["key1"] = "Value1"; // 加入值对 map["key2"] = "Value2"; map["key3"] = "Value3"; for(var k in map) { // 遍历 alert(k + " = " + map[k]); } var mykey="key1"; alert("key1的数值"+map[mykey] ); delete map["key1"]; // 删除 var mykey="key5"; if(mykey in map){//判断是否存在 alert(mykey+"的数值"+map[mykey] ); }else{ alert("不存在"+mykey+"的数值"); } </script>