¡GoConqr estrena diseño! Cuéntanos qué te parece.

Módulo 9 de 10 · Multimedia

Set Data Structure

Kostas Diakogiannis

Set Data Structure

The Set data structure

Set is an iterable JavaScript object that came through ECMA Script 6. It works like an array, the main difference is that it is primarily used for storing there unique values and it does NOT allow duplicates. 

The way to create a set is with the new Set() constructor. Inside the set you can pass an array as a seeding data, and all the data of the array is going to be used in order to be valid for data for a set (remove duplicates etc).

Some of the commonest methods when working with sets include: 

1. let mySet = new Set() // Creates a new empty set.

2. mySet.add('something') // Adds the value of something to mySet.

3. mySet.delete('something') // Deletes the value of 'something' from mySet.

4. mySet.has('something') // Returns a boolean if mySet contains a value of something

5. mySet.size // Returns a property of size (equivalent to length for arrays)

Instrucciones

Para avanzar en el curso, envía un intento de este test. Puedes enviarlo después de la última pregunta.

Ir al módulo elegido

Escríbenos

¿Sobre qué es tu mensaje?

¿Qué te parece el nuevo diseño?

¿Te gusta?