当前位置:网站首页>Map structure
Map structure
2022-07-27 08:18:00 【huijie_ 0716】
One 、map Object creation
var x=new Map();
var map1 = new Map([
['a', 1],
['b', 2],
['c', 1]
]);
Two 、 increase / add to
x.set(Symbol('a'),' Zhang San ');
x.set(Symbol('a'),' Li Si ');
x.set(' zhengzhou ',' a sunny day ');
x.set(' kaifeng ',' cloudy ');
3、 ... and 、 modify
x.set(' kaifeng ',' a sunny day ');
Four 、 lookup
console.log(x.has(' luoyang ')); return true or false
5、 ... and 、 Delete
x.delete(' kaifeng ');
x.clear(); Empty
6、 ... and 、 Traverse
x.forEach(function(val,key,map){ console.log(val,key) })
7、 ... and 、 keys /values /entries
for(let i of x.keys()){
console.log(i);
}
for(let i of x.values()){
console.log(i);
}
for(let i of x.entries()){
console.log(i);
}
for(let i of x){
console.log(i);
}8、 ... and 、 map transformation key Relationship with value
var map1 = new Map([
['a', 1],
['b', 2],
['c', 1]
]);
var map2 = new Map([
[' zhengzhou ', ' a sunny day '],
[' kaifeng ', ' cloudy '],
[' Tokyo ', ' tsunami '],
[' xinxiang ', ' tsunami ']
]);
function mapchenge(map) {
console.log(map);
let tem_map=new Map();// empty map aggregate
for(let i of new Set(map.values())){// Iteration after de duplication
tem_map.set(i,[]);// Add data to map aggregate
}
// Add source value To new map
for(let [i,j] of map){
tem_map.get(j).push(i);
}
return tem_map;
}
var y = mapchenge(map1);
var x = mapchenge(map2);
console.log(y);
console.log(x);边栏推荐
- 关于数据库的接口响应非常慢
- Why do major domestic manufacturers regard cloud computing as a pastry? Do you really understand this trillion market
- [netding cup 2020 rosefinch group]nmap 1 two solutions
- 1178 questions of Olympiad in informatics -- ranking of grades
- SETTA 2020 国际学术会议即将召开,欢迎大家参加!
- 一段平平无奇的秋招经历
- STM32小bug汇总
- 开怀一笑
- Mqtt instruction send receive request subscription
- Qt Creator代码风格插件Beautifier
猜你喜欢

How to obtain the cash flow data of advertising services to help analyze the advertising effect?

Virtual machine cloning

好吃难吃饱七分为宜;好喝难喝醉三分为佳
![[MRCTF2020]Ezpop 1](/img/c0/41873fe5864490ade403eeddc26976.png)
[MRCTF2020]Ezpop 1

SSTI template injection

ERP production operation control Huaxia

On data security

Vcenter7.0 managing esxi7.0 hosts

OSI seven layer model and tcp/ip four layer (TCP and UDP) (notes)

Leetcode54. Spiral matrix
随机推荐
如何卸载--奇安信安全终端管理系统
Record a PG master-slave setup and data synchronization performance test process
情人节,我用字符画出了一个对象!
How does kettle handle text data transfer as' 'instead of null
开怀一笑
Stored procedure test 1 -- first acquaintance of love
Solid smart contract development - 3.3-solid syntax control structure
Leetcode56. Consolidation interval
"PHP Basics" use of integer data
XxE & XML vulnerability
2022/7/26 exam summary
End of year summary
1024 | in the fourth year officially called Menon, the original intention is still there, and continue to move forward
Mqtt instruction send receive request subscription
Shell scripts related
You may need an additional loader to handle the result of these loaders.
Ubuntu: install PostgreSQL
On Valentine's day, I drew an object with characters!
2020 International Machine Translation Competition: Volcano translation won five championships
Data extraction 2