Set,Map

Posted yaoya

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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‘]

 

以上是关于Set,Map的主要内容,如果未能解决你的问题,请参考以下文章