//使用map构造数组结构
const m = new Map([[1, "xm"], [2, "hh"], [3, "mm"]])
//遍历
for(let key of m.keys()){
console.log(key);
}
for(let value of m.values()){
console.log(value);
}
for(let item of m.entries()){
console.log(item);
}
for(let [key,value] of m.entries()){
console.log(key,value);
}
for(let [key,value] of m){
console.log(key,value);
}
//forEach
m.forEach(function(value,key,map){
console.log(value+"--"+key+"--"+map)
console.log(this);
})
m.forEach(function(value,key,map){
console.log("forEach"+this);
},m);
//获取map数组长度
console.log(m.size)
//查询是否存在
const hasM = m.has(1);
console.log(hasM);
//获取
const getM = m.get(1);
console.log(getM);
//设置
m.set([4,"我是4"]);
console.log(m.get(4));
//删除
m.delete(1);
for(let [key,value] of m){
console.log(key,value);
}
//清除
m.clear();
for(let [key,value] of m){
console.log(key,value);
}
console