首页 > 代码库 > <<< Js对map的操作

<<< Js对map的操作

var map = {};// 赋值var key = "key1";var value = "http://www.mamicode.com/value1";map[key] = value;// 取值alert(map[key]);if("key1" in map) { //判断是否存在    alert("OK");}// 删除delete map["key1"];// 遍历for(key in map){    console(key + map[key]);}