I would like to create a map in JavaScript with two keys or need to know if there is a better solution. I need to know if key1 is part of the collection and if so get data1 and in another case I need to know if a value of type key2 is part of the collection and get its data. How do you do this in JavaScript?
Example:
const contacts = new Map();
contacts.set('key_person', {phone: "617-555-4321", address: "321 S 2nd St"});
const contacts2 = new Map();
contacts.set('key_city', {phone: "617-555-4321", address: "321 S 2nd St"});
At the moment I have maps with redundant information in order to get data by key_person
and key_city
. I want a joint map where I can filter for both keys at a time. Thanks you