On Nov 30, 2010, at 3:25 PM, Fyodorov Bga Alexander wrote:

> @apipkin have found logic bug
> `{valueOf: function(){ return 1 }} == {valueOf: function(){ return 1 }}`
> // false
> `{valueOf: function(){ return 1 }} >= {valueOf: function(){ return 1 }}`
> // true, ok

This is not a bug in ES5, although you could argue it's a design flaw in JS. 
Recall that

typeof a == typeof b && a == b <=> a === b  // implies, in both directions

Two object initialisers never evaluate to the same object reference, and === 
compares references, and == here has same-typed (object) operands, so it is the 
same as ===.

Relational operators do convert objects. You could argue this is a design flaw; 
or that this is a win but then == should convert objects as well -- but if that 
is a flaw, it's only in hindsight, since === came after == and without === 
there would be no way to distinguish object references without implicit 
conversion.

Really, implicit conversions (not the same as operator methods) are a design 
flaw in my view. They make == (ignoring NaN) not an equivalence relation.

But again, not an ES5 bug. Did you read ES1-3 on == and valueOf differently?

/be

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to