Custom objects comparison

Hello,

Based on what are two objects compared?

I have an embedded object, actually an int32, that implements valueOf and toString.

I need to compare some object having a value against other object, havingsome value (possibly the same value, but different instance).

How do I get a comparison result for two instances based on their private values?

Thank you,
Mike
0
Mihai
1/9/2017 9:52:35 AM
mozilla.dev.tech.js-engine 1994 articles. 0 followers. Post Follow

3 Replies
51 Views

Similar Articles

[PageSpeed] 37

On 1/9/17 4:52 AM, Mihai Dobrescu wrote:
> Based on what are two objects compared?

Compared in what sense?

-Boris
0
Boris
1/9/2017 5:44:59 PM
On Monday, January 9, 2017 at 7:45:05 PM UTC+2, Boris Zbarsky wrote:
> On 1/9/17 4:52 AM, Mihai Dobrescu wrote:
> > Based on what are two objects compared?
> 
> Compared in what sense?
> 
> -Boris

Having 2 instances of the same types, each with a private date of the same type, like int32 value of 0 in each, I would need to get true from the javascript comparison (a == b).
0
Mihai
1/9/2017 7:12:04 PM
On Mon, Jan 9, 2017 at 8:12 PM, Mihai Dobrescu <msdobrescu@gmail.com> wrote:

> Having 2 instances of the same types, each with a private date of the same
> type, like int32 value of 0 in each, I would need to get true from the
> javascript comparison (a == b).
>

That's not possible. When a and b are objects, the engine compares the two
pointers and there's no way to override that atm.

HTH,
Jan


> _______________________________________________
> dev-tech-js-engine mailing list
> dev-tech-js-engine@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-tech-js-engine
>
0
Jan
1/9/2017 7:41:54 PM
Reply: