I was playing around with JSconsole and found something strange. The value of "0"
is false
"0" == false
=> true
The value of false
when used in ternary returns the second value
false ? 71 : 16
=> 16
However the value "0"
which equals false
when used in ternary returns the first value.
"0" ? 8 : 10
=> 8
However, if you use 0
as the value, it returns the second value
0 ? 4 : 5
=> 5
0 == "0"
=> true
I'm afraid this doesn't make sense to me.