Here is a javascript comparison:
2 == true //false
it's said, the reason why return false, is because the comparison convert the true
to Number
datatype, and result is 1:
console.info(Number(true)) // 1
My confuse is, why the comparison don't convert the number 2
to Boolean
datatype
console.info(Boolean(2)) // true
and the 2 == true
result could be true
?
Best Answer
I find the doc here:
Comparison Operators, which said: