js 中使用map

js 中使用map

  (2014-04-25 15:20:55)
转载
标签: 

js

 

map

 

it

分类: java
var map = {}; // Map map = new HashMap();
map[key] = value; // map.put(key, value);
var value = map[key]; // Object value = map.get(key);
var has = key in map; // boolean has = map.containsKey(key);
delete map[key]; // map.remove(key);
// 遍历  
for(key in map){  
    alert(key + map[key]);  
}  
//长度判断
var length  = Object.keys(map).length ;


参考:http://stackoverflow.com/questions/5223/length-of-javascript-object-ie-associative-array

你可能感兴趣的:(js 中使用map)