From 564631b29bc62a4e35b0aee5662a11216a06dea8 Mon Sep 17 00:00:00 2001 From: mhrooz Date: Tue, 18 Jun 2024 09:08:38 +0200 Subject: [PATCH] map init --- 5.6Map/t.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 5.6Map/t.js diff --git a/5.6Map/t.js b/5.6Map/t.js new file mode 100644 index 0000000..ef807fb --- /dev/null +++ b/5.6Map/t.js @@ -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)); +