I'm new to javascript, thus the question. I've the following object,
class Node{ constructor(data){ this.data = data; this.adjacencySet = new Set(); } addEdge(node){ this.adjacencySet.add(node) } getAdjacentVertices(){ return this.adjacencySet; } } How do I check the presence of this object in a hash map. An analogy would be in Python I'd add the following method in the class,
def __eq__(self, other): return this.data == other.data How can do a similar object comparison in javascript?
==object comparison in JavaScript is always based on the actual identity of the objects. Two different objects are never==no matter how similar they are.MaporSet, which I think is what the OP wanted to achieve.