forked from mouredev/hello-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11-set.js
More file actions
47 lines (30 loc) · 693 Bytes
/
11-set.js
File metadata and controls
47 lines (30 loc) · 693 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//set
//Declaracion
let myset = new Set()
let myset2={}
//Inicializandolo
myset = new Set (["Oliver","Rustrian","olirustrian",20,true,"algo"])
myset2= new Set()
console.log(myset)
console.log(myset2)
//Métodos comunes
//add y delete
myset.add("nuevo DAto")
console.log(myset)
myset.delete("Rustrian")
console.log(myset)
//has
console.log(myset.has("Oliver"))
console.log(myset.has("Rustrian"))
//size
console.log(myset.size)
//convertir un set a array
let myarray = Array.from(myset)
console.log(myarray)
myset3 = new Set(myarray)
console.log(myset3)
//los set no admite duplicados
myset.add("nuevo DAto")
myset.add("nuevo DAto")
myset.add("Nuevo Dato")
console.log(myset)