0

Let's say I create a Map object and set some keys to values and end up with something like this:

{"a" => 1, "b" => "hello", 3 => {"c": true}, {a: 1} => "hi"};

I can access the "a", "b", and 3 keys by using myMap.get("a"), myMap.get("b"), and myMap.get(3) respectively, but I can't seem to do myMap.get({a:1}). This probably has to do with the fact that objects are passed by reference.

How do I access the value of keys that are objects using the Map API?

embracethefuture
  • 515
  • 7
  • 17
  • This is not a valid JS `Map` syntax, it looks more like PHP? – Bergi Jun 13 '21 at 23:29
  • "*This probably has to do with the fact that objects are passed by reference.*" - yes. "*How do I access the value of keys that are objects using the Map API?*" - well, use the **same** object. – Bergi Jun 13 '21 at 23:30

0 Answers0