1.数组转map:必须是二维数组
var arr=[[1,'hello'],[2,'h5']]
var m1=new Map(arr)
console.log(m1);
2.map转数组:Array.from()静态方法
var arr=[[1,'hello'],[2,'h5']]
var m1=new Map(arr)
var arr2=Array.from(m1)
console.log(arr,m1,arr2,arr==arr2);
//(2) [Array(2), Array(2)] Map(2) {1 => 'hello', 2 => 'h5'} (2) [Array(2), Array(2)] false
3.数组转集合
var arr = [100,200,100,{age:20},{age:20}]
var s1=new Set(arr)
console.log(s1); //Set(4) {100, 200, {…}, {…}}
4.集合转数组
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]);//(4) [100, 200, {…}, {…}] true