Get the App
SLTechnology News&Howtos  ›  Development  › 

How ES6 combines the Set collection to create an array without repeating elements

Shulou Source: shulou.com Published: 2022-06-01 04:39:47 10月25日 Update

This article is about how ES6 combines the Set collection to create an array without repeating elements. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Combine the Set collection to create an array without repeating elements

Function eliminateDuplicates (items) {return [... new Set (items)]} let numbers = [1 numbers 2 3, 3, 3 4 numbers 5]; let noDuplicates = eliminateDuplicates (numbers); console.log (noDuplicates); / / [1 line 2, 3 new Set 4 5] Thank you for reading! This is the end of the article on "how ES6 combines the Set collection to create an array of non-repeating elements". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Tags: Array no weight content more articles good practical articles read knowledge reference help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Tech Info Redmi Huawei vpn