See Abstract Equality Comparison::
The comparison x == y
, where x and y are values, produces true or false. Such a comparison is performed as follows:
So, in your situation, x
is a string, and y
is a boolean. The first condition that is fulfilled here is:
- If Type(y) is Boolean, return the result of the comparison
x == ToNumber(y)
.
Turning the check into
'' == 0
Which then fulfills:
- If Type(x) is String and Type(y) is Number, return the result of the comparison ToNumber(x) == y.
And ToNumber('') === 0
:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…