Get the App
SLTechnology News&Howtos  ›  Development  › 

How to remove duplicates in JavaScript Array

Shulou Source: shulou.com Published: 2022-06-03 09:15:10 11月15日 Update

This article mainly introduces how JavaScript arrays can be de-weighted. It has certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let Xiaobian take you to understand it together.

Method 1: set: not a data type, a data structure; unique member let arr = [12,1,12,3,1,88,66,9,66];function unique(ary) { let s = new Set(ary); // Array.from : convert the set data structure to a real array; return Array.from(s) } unique(arr); method 2: object attribute name cannot be repeated let arr = [12,1,12,3,1,88,66,9,66];function unique(ary) { let obj = {}; for(let i=0;i

Tags: Methods arrays attributes data articles members data structures structures functions objects values interests parameters at the same time Boolean more friends features knowledge for the first time Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux macOS OPPO Reno Shulou Tech Info Shulou Technology