Quantcast

Custom objects comparison

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Custom objects comparison

Mihai Dobrescu
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
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Custom objects comparison

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

Compared in what sense?

-Boris
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Custom objects comparison

Mihai Dobrescu
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).
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Custom objects comparison

Jan de Mooij-2
On Mon, Jan 9, 2017 at 8:12 PM, Mihai Dobrescu <[hidden email]> 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
> [hidden email]
> https://lists.mozilla.org/listinfo/dev-tech-js-engine
>
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Loading...