当前位置:网站首页>ES6 -- conversion of arr (array) -map set
ES6 -- conversion of arr (array) -map set
2022-07-16 05:54:00 【Like to drink pearl milk tea】
Tips : When the article is finished , Directories can be generated automatically , How to generate it, please refer to the help document on the right
List of articles
Catalog
1. Array rotation map
Must be a two-dimensional array
var arr=[[1,"hello"],[2,"h5"],[3,{name:"karen"}]]
var m1=new Map(arr)
console.log(m1);Running results :

2.map Turn array
Array.from() Static methods
var arr=[[1,"hello"],[2,"h5"],[3,{name:"karen"}]]
var m1=new Map(arr)
var arr2=Array.from(m1)
console.log(arr,m1,arr2,arr==arr2,arr[2][1]==arr2[2][1])Running results :

3. Array to set
var arr=[100,200,100,{age:20},{age:20}]
var s1=new Set(arr)
console.log(s1,s1.size)Running results :

4. Set array
var arr=[100,200,100,{age:20},{age:20}]
var s1=new Set(arr)
var arr2=Array.from(s1)
console.log(arr2,arr[4]==arr2[3])Running results :

5. Multiple arrays to sets and map
var arr1=[10,20]
var arr2=[100,20]
var arr3=[200,{name:"karen"}]
var s1=new Set([...arr1,...arr2,arr3])
var m1=new Map([arr1,arr2,arr3])
var m2=new Map(m1)
console.log(m1,m2,m1==m2,m1.get(200)==m2.get(200))
var mySet=new Set(" hel lo Huaqing vision \n")
console.log(mySet);Running results :

边栏推荐
- win10下测试mysql主从同步
- Clues in buuctf packets
- Cross domain exceptions where the admin system is nested in a third-party system
- [安洵杯 2019]easy_web
- Automated machine learning
- JS downloads files according to binary data
- Buuctf webshell back door
- C3&H5&ES6
- Network security emergency response - electronic data forensics technology
- 移动web开发
猜你喜欢

服务器对接码云webhooks实现自动部署--超详细--PHP

DVA data flow

Memo, usememo, usecallback summary

网络通信安全部分笔记——OSPF理论及实验

Network security emergency response - electronic data forensics technology

Collect form data

win10下测试mysql主从同步

Clues in buuctf packets

Operating system notes - Windows emergency response and security hardening
![[Huang ah code] today, someone actually asked me: what does where 1=1 mean?](/img/66/2413c1cfb39e6384dc2fa8af276e9e.png)
[Huang ah code] today, someone actually asked me: what does where 1=1 mean?
随机推荐
[Huang ah code] you must learn these little knowledge points of MySQL for beginners
Cross domain exceptions where the admin system is nested in a third-party system
Convert list data to tree data
: class modify style
Automated machine learning
[Huang ah code] PHP realizes file download and supports continuous transmission at breakpoints
Buuctf mysterious Tornado
Memory forensics - installation and use of volatility and some CTF competition topics
[node] node create server +mysql store data minimalist demo
North tour project notes
淘宝项目练习总结
服务器对接码云webhooks实现自动部署--超详细--PHP
Network security emergency response - common tools
Svelte official introductory tutorial (5) - Events
Svelte official introductory tutorial (4) -- template logic
手摸手教学-利用原生POI对excel的导入导出以及阿里的easyexcel的基本操作
Collect form data
win10下测试mysql主从同步
网络安全应急响应-基础技能
[Huang ah code] PHP cooperates with wechat official account to generate promotion QR code