Hi everyone! I'm the author of code.mu :)
I'd love to chat with my non-Russian audience. I'm looking for your feedback on the site and the translation quality. Let's chat:)
⊗jsSpStInr 37 of 294 menu
◀ ▶

Set collections in JavaScript

Set collections allow you to create arrays without duplicates. Let's see how to work with such collections. First you need to create a collection with the following command:

let set = new Set;

Once the collection has been created, new elements can be added to it using the add method:

let set = new Set; set.add(1); set.add(2); set.add(3);

At the same time, when trying to add an element that already exists in the collection, this element will not be added:

let set = new Set; set.add(1); set.add(2); set.add(3); set.add(3); // will not be added, because it already exists

Create a Set collection. Use the add method to add elements to it. Make sure there are no duplicate elements added.

← →
↑
English▼
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline