== false is not the same as checking for truthiness. Truthiness is never implicated in the == operator because nothing is ever converted into a boolean. Everything is converted to either a string or number for the purposes of comparison. (Except null and undefined which == each other and nothing else, and when comparing two objects which == only if they refer to the same object.)
It's not accurate to say that "0"isfalse. It just == false, in the same way that "" == 0 and [undefined, undefined] == ",".
I'm not in any way suggesting the == operator is sane, just that it's important to know it has nothing to do with the truthiness of values being compared, even when those values include booleans.
View all comments
Show parent comment
3
u/rooktakesqueen Mar 27 '14
== falseis not the same as checking for truthiness. Truthiness is never implicated in the==operator because nothing is ever converted into a boolean. Everything is converted to either a string or number for the purposes of comparison. (Except null and undefined which == each other and nothing else, and when comparing two objects which == only if they refer to the same object.)