Js对map的操作
var map = {}; // 赋值 var key = "key1"; var value = "value1"; map[key] = value; // 取值 alert(map[key]); if("key1" in map) { //判断是否存在 alert("OK"); } // 删除 delete map["key1"]; // 遍历 for(key in map){ console(key + map[key]); }
var map = {}; // 赋值 var key = "key1"; var value = "value1"; map[key] = value; // 取值 alert(map[key]); if("key1" in map) { //判断是否存在 alert("OK"); } // 删除 delete map["key1"]; // 遍历 for(key in map){ console(key + map[key]); }