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']

 

posted @ 2018-11-14 17:30  红枣味酸奶  阅读(117)  评论(0编辑  收藏  举报