This commit is contained in:
mhrooz 2024-06-18 09:08:38 +02:00
parent d9bba74979
commit 564631b29b

18
5.6Map/t.js Normal file
View File

@ -0,0 +1,18 @@
let map = new Map();
map.set('1', 'first');
map.set(1, 'second');
map.set(true, 'third');
console.log(map.get('1'));
console.log(map.get(1));
console.log(map.get(true));
console.log(map.size);
// we should use the map.get() method, not map[] so that we can use the feature of the map, ot the map can only get the value from number and string
let person = {name: 'John'};
map.set(person, 'hi');
console.log(map.get(person));