I thought I knew about the quirks with ==
and all the strange type casts in JavaScript, but today I stumbled upon one thing that doesn't make any sense to me:
'\t' == false
// => true
Why is that?
Apparently, '\t'
is not a falsy value, and if combined with ||
it works as excpected:
'\t' || 42
// => '\t'
On the other hand, a toString
is also not called on false
, see:
'\t' == 'false'
// => false
This led me to thinking that the tab maybe gets converted to a boolean, but:
Boolean('\t') == false
// => false
So, the question is: Why is that?