js Map 工具类 MapUtil

var MapUtil = {}

 

MapUtil.keyset = function(m){

var result = new Array();

for(var i in m){

result.push(i);

}

return result;

}

 

MapUtil.values = function(m){

var result = new Array();

for(var i in m){

result.push(m[i]);

}

return result;

}

 

MapUtil.valuesSet = function(m){

var result = {};

for(var i in m){

var tmp = m[i];

result[tmp] = 1;

}

return MapUtil.keyset(result);

}

你可能感兴趣的:(js,array,map,keyset)