The spec says, in the ninth clause of https://www.ecma-international.org/ecma-262/#sec-abstract-equality-comparison, that if the right side is boolean, then the right side will become a number. That is;
[] == ![][] == false[] == 0
Now, the spec (in the eleventh clause of the aforementioned section) says that an object on the left side (this is, being x) compared to a number will reduce to ToPrimitive(x) == y. Calling ToPrimitive on an array A is the same as calling A.join(), and [].join() === "". That is;
[] == 0"" == 0 //true
Thus, it is not true (as we are saying in our first example) that both operands get converted to 0 (moreover, they are not being both converted to numbers). Can I please send a PR if this reasoning is valid?
The spec says, in the ninth clause of https://www.ecma-international.org/ecma-262/#sec-abstract-equality-comparison, that if the right side is boolean, then the right side will become a number. That is;
[] == ![]
[] == false
[] == 0
Now, the spec (in the eleventh clause of the aforementioned section) says that an object on the left side (this is, beingx
) compared to a number will reduce toToPrimitive(x) == y
. CallingToPrimitive
on an arrayA
is the same as callingA.join()
, and[].join() === ""
. That is;[] == 0
"" == 0 //true
Thus, it is not true (as we are saying in our first example) that both operands get converted to 0 (moreover, they are not being both converted to numbers). Can I please send a PR if this reasoning is valid?