0 == ''
The left operand is of type Number.
The correct operand is of type String.
In this case, the right operand is forced to the Number type:
0 == Number('')
that leads to
0 == 0
From the "strong" abstract equality comparison algorithm (number 4):
If Type (x) is Number and Type (y) is String, return the result of the comparison x == ToNumber (y).
Source: http://es5.github.com/#x11.9.3
Ε ime Vidas Sep 30 2018-11-11T00: 00
source share