I'm having some troubles while checking if a map already has an object as key.
e.g.
const myMap: Map<MyObject1, MyObject2> = new Map<MyObject1, MyObject2>();
I also defined an equals function in MyObject1 class
equals(other: ThreatAgentMgm): boolean {
return other.id === this.id;
}
but myMap.has(myObject1) is always false.
I read theat the has method is based on the === operator, should I define something else in MyObject1 class?
equals()method when comparing objects for equality. Why don't you just make your map key theidfield ofMyObject1and then domyMap.has(myObject1.id)?Setand notMapbut it's about the same issue: key equalityMapin JavaScript is not the same asMapin Java, and neither of those are JSON. 🤷♂️