class Sample {
constructor(value) {
this.#internal = value
}
[Symbol.equal](input) {
if (input instanceof Sample) {
return this.#internal === input.#internal
}
return false
}
}
const foo = new Sample(1)
const bar = new Sample(1)
foo === bar // here change `Strict Equality Comparison` semantics?
Object.is(foo, bar) // ?
// or new grammar?
References:
- https://tc39.es/ecma262/#sec-object.is
- https://tc39.es/ecma262/#sec-strict-equality-comparison
- https://tc39.es/ecma262/#sec-abstract-equality-comparison
- https://github.com/NiceLabs/proposal-arraybuffer-equal
- https://github.com/tc39/proposal-array-equality
- https://github.com/tc39/proposal-record-tuple
In general this seems like a good goal, and assuming we have a Symbol protocol, would be relatively trivial to achieve.
This idea from @ljharb (email conversation)