对象类似于数组,且成员的值都是唯一的

constarr=[1,2,3,4,5,5,4,3,2,1]

constset=newSet()

arr.forEach(item=>set.add(item))

console.log(set)//1,2,3,4,5

//数组快速去重

console.log([...newSet(arr)])

Map对象是键值对集合,和JSON对象类似,但是key不仅可以是字符串还可以是对象

varmap=newMap()

varobj={name:'小缘',age:14}

map.set(obj,'小缘喵')

map.get(obj)//小缘喵

map.has(obj)//true

map.delete(obj)//true

map.has(obj)//false