loading
index.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
65
66

// let data = new Map();

// let val = {
//   id : 1
// }

// console.log(data instanceof Object);

// console.log(val instanceof Map);


// data.set(1,{ address : {
//   country : "India",
//   postal : 123456
// } });
// data.set(2,{ address : {
//   country : "US",
//   postal : 123456
// } });

//get all the elements in the map
// console.log(data);

//getting specific element using key
// console.log(data.get(1));
// console.log(data.get(2));

//getting size of map
// console.log(data.size)

//deleting item from map
// console.log(data.delete(2))
// console.log(data)

//deleting all items in the map
// data.clear();

//iterating over map keys
// for (const k of data.keys()) {
//   console.log(k)
// }

//iterating over map values
// for (const k of data.values()) {
//   console.log(k)
// }


//iterating over map key,value pairs
// for (const [k,v] of data) {
//   console.log(k,v);
// }


let user = {
  name : "Steve"
}

let weakMap = new WeakMap();
weakMap.set(user, "check");

user = null; // overwrite the reference

console.log(weakMap)