JSPM

arrayheavy

1.2.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • 0
    • Score
      100M100P100Q14191F
    • License ISC

    delete repeat content for arr

    Package Exports

    • arrayheavy
    • arrayheavy/index.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (arrayheavy) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    安装:

    npm i arrayheavy

    思路:

    1.目标:把旧数组里面不重复的元素选取出来放到新数组中,重复地元素只保留一个,放到新数组中去重

    2.核心算法:我们遍历旧数组,然后拿着旧数组元素去查询新数组,如果该元素在新数组中没有出现过就添加,否则就不添加

    3.利用 新数组.indexOf(数组元素)如果返回值是-1 , 就说明新数组里面没有该元素