5 ms·
Well, at least it's got some symmetry to it!
by prezjordan 12y ago
Well, at least it's got some symmetry to it!
- skrebbel 12y agoThat's actually pretty important: it means that == and != are commutative. Imagine the "wat" if that wasn't the case either. And hey, it's JS, it could've been.
- sheetjs 12y agoCommutative 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 == ""
- deleted 12y ago[deleted]