Constclass Point implements Equatable {
constructor(readonly x: number, readonly y: number) {}
[equalsSymbol](other: unknown): boolean {
return other instanceof Point && other.x === this.x && other.y === this.y
}
[hashCodeSymbol](hash: HashFunction): number {
return hash(this.x) * 31 + hash(this.y)
}
}
The key of the method by which an object compares itself with another for value equality.
a[equalsSymbol](b)returnstrueorfalse. It is used only when both values implement it, and only together with hashCodeSymbol: equal objects must return the same hash. The key isSymbol.for('javascript-collections-framework.equals')and does not change between major versions.Time: O(1) to read; the method's cost is the implementer's.