23 ms·
Commutative but not transitive, as in the example var x = {toString:function() { return "foo"; } }, y = "foo", z = new String("foo") x == y and y == z but
by sheetjs 12y ago
Commutative but not transitive, as in the example
var x = {toString:function() { return "foo"; } }, y = "foo", z = new String("foo")
x == y and y == z but x != z
- _asummers 12y agoThis implies there is no equivalence relation with == in JS. In order to form an equivalence relation, it would need to be reflexive, symmetric and transitive.
- stromgo 12y agoMany such examples can be spotted in the table: [] == 0 == [[]] [1] == true == [1] ... There are even two examples with self-equality (x == x && y == y && z == z): "0" == false == "" "0" == 0 == ""