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:
- ECMAScript® 2024 Language Specification
- ECMAScript® 2024 Language Specification
- ECMAScript® 2024 Language Specification
- GitHub - JSCIG/proposal-arraybuffer-equal: Compare two ArrayBuffers byte-wise for equality
- GitHub - tc39/proposal-array-equality: Determining Array Equality
- GitHub - tc39/proposal-record-tuple: ECMAScript proposal for the Record and Tuple value types. | Stage 2: it will change!
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)