-1 == true; // false
-1 == false // false
-1 ? true : false; // true
Can anyone explain the above output? I know I could work round t
In most systems, non-zero values are considered a true value, but that doesn't necessarily mean that they are the same true value as true
. Thus, -1 == true
doesn't necessarily hold, but -1
can still be considered a true value since it is non-zero.
Really, though, you shouldn't be comparing integers to booleans if you can avoid it.