In Javascript, I know that {foo: 'bar'} !== {foo: 'bar'}
. That's fine, and if I really want to check if two objects are equal, I can write my own utility method that loops through the properties. But what if I want to use objects or arrays in a Set
, or as the keys in a Map
?
I want some way so that this code works as expected:
let map = new Map();
map.set({foo: 'bar'}, 2);
map.get({foo: 'bar'}); // returns 2