ES6 set集合简介
1、去重const arr = [1,1,2,2,]const arr2 = [...new Set(arr)]2、判断元素是否在集合中const arr = [1,1,2,2]const set = new Set(arr)const has = set.has(3)3、求交集const arr = [1,1,2,2]const set = new Set(arr)const set2 = new Set([2,3])const set3 = new Set([..
原创
2021-10-23 20:41:08 ·
86 阅读 ·
0 评论