forked from mouredev/hello-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
12-map.js
67 lines (39 loc) · 854 Bytes
/
12-map.js
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
Clase 4 en vídeo | 31/07/2024
Mapas, bucles y funciones
https://www.youtube.com/live/xg1GeHKiNzU?si=oiWHK8bDTZ1c98hF&t=885
*/
// Map
// Declaración
let myMap = new Map()
console.log(myMap)
// Inicialiación
myMap = new Map([
["name", "Brais"],
["email", "[email protected]"],
["age", 37]
])
console.log(myMap)
// Métodos y propiedades
// set
myMap.set("alias", "mouredev")
myMap.set("name", "Brais Moure")
console.log(myMap)
// get
console.log(myMap.get("name"))
console.log(myMap.get("surname"))
// has
console.log(myMap.has("surname"))
console.log(myMap.has("age"))
// delete
myMap.delete("email")
console.log(myMap)
// keys, values y entries
console.log(myMap.keys())
console.log(myMap.values())
console.log(myMap.entries())
// size
console.log(myMap.size)
// clear
myMap.clear()
console.log(myMap)