Set,Map

  可以使用Set集合的不可重复性来处理js的数组去重:

const arr = [1, 2,null,'hellow', 'hellow', 2, null]
let set = new Set(arr);
console.log(Array.from(set)) // [1,2,null,'hellow']
console.log([...set]) // [1,2,null,'hellow']

猜你喜欢

转载自www.cnblogs.com/yaoya/p/9959162.html
今日推荐