1.数组转map
必须是二维数组
var arr=[[1,"hello"],[2,"h5"]]
var m1 = new Map(arr)
2.map转数组
Array:from()静态方法
var arr2=Array.from(m1)//内部的引用数据也会重新创建
console.log(arr,m1,arr2,arr==arr2,arr[2][1]==arr2[2][1])
3.数组转集合
var arr=[100,200,100,{age:20},{age:20}]
var s1=new Set(arr)
console.log(s1,s1.size)
4.集合转数组
var arr2=Array.from(s1)
console.log(arr,s1,arr2,arr[4]==arr2[3])
5. 多个数组转集合和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))