一、set(添加)
var myMap = new Map();
1.
myMap.set(keyString, "和键'a string'关联的值");
2.
for (var i = 0; i < this.tableData.length; i++) {
let n = this.tableData4[i].Id + '-' + this.tableData4[i].name
this.myMap .set(n, this.tableData[i].bdwant)
}
3.
myMap.set(keyString, {name:"和键'a string'关联的值"});
二、get(查找)
this.myMap .get(row.recive)
三、has(返回是否存在)
myMap.has(arr)
四、delete(删除)
myMap.delete(key);
五、clear(清除所有)
map.clear()
六、key与valus
var map = new Map()
.set('aa',11)
.set('bb',22)
for(let key of map.keys()){
console.log(key)
}
for(let value of map.values()){
console.log(value)
}
myMap.forEach(function(value, key) {
console.log(key + " = " + value);
}, myMap)
七、map的合并、转换
var merged = new Map([...first, ...second]);
var map = new Map()
.set('aa',11)
.set('bb',22)
.set('cc',33)
[...map]
[...map.keys()]
[...map.values()]
[...map.entries()]
|