dictionary - Unable to retrieve value from a Map with object of identical values -


i want construct lookup table object key. find cannot construct key same values retrieve value in table.

const makekey = (a, b) => (    {a,      b,}  );    const lookup = new map();    lookup.set(makekey(1, 2), 'yes');  lookup.set(makekey(3, 7), 'no');  console.log(lookup.keys());    const k = makekey(1, 2)    console.log(k);  console.log(lookup.get(k));  // want yes, undefined instead

it seems map uses object identity find hit.

how can use object's value key?

i end change way key generated:

const makekey = (a, b) => {   const k = {a, b};   return `${object.values(k)}` }; 

the key string


Comments