美文网首页
Set数组去重

Set数组去重

作者: 秀萝卜 | 来源:发表于2022-07-11 10:58 被阅读0次
// 数组去重
let arr1 = [1,2,3,4,6,3,1,8]
let arr2 = Array.from(new Set([...arr1]))
console.log(arr2)
// 多个数组去重
let arr3 = [1,2,3,4,6,3,1,8]
let arr4 = [1,3,5,9,11]
let arr5 = Array.from(new Set([...arr3,...arr4]))
console.log(arr5)

参考资料:
https://blog.csdn.net/weixin_45112114/article/details/123231261

相关文章

  • 使用Set进行数组去重

    关键词:ES6,set,Array.from(set),[...set],数组去重 使用Set进行数组去重方法,如...

  • 解构,...展开数组

    数组 对象 [...set(arr)]数组去重

  • 数组去重

    数组去重: 1、数组去重: 2、[...new Set(arr)] 3、 for 循环嵌套for,splice 去...

  • Set和Map数据结构

    Set函数传一个数组或者伪数组,返回一个set构造函数,具有数组去重功能 set函数是具有数组去重的功能的,这应该...

  • set 数组去重

    ES6出现了一个新的方法,在面试中个多次被提问到那就是数组去重 1.通过Set去重 例如:var arr = [3...

  • Set数组去重

    参考资料:https://blog.csdn.net/weixin_45112114/article/detail...

  • JS实现数组去重常用的六种方法

    双重for循环去重 includes实现数组去重 indexOf实现数组去重 利用set方法去重 ES6 Arra...

  • js 数组快速去重

    通过set 数组新特性去重

  • es6中set的使用方式

    es6中的set主要是作用是一是对数组去重,set的将数组去重实例化 ,二是对数组交集 合并、差集 set的的方法...

  • ES6学习笔记之数组

    使用set对象给数组去重[...new Set(array)] 字符串数组转数字数组['1', '2', '3']...

网友评论

      本文标题:Set数组去重

      本文链接:https://www.haomeiwen.com/subject/iezobrtx.html