In JavaScript…
'\t\n ' == false // true
I can assume that any string that consists solely of whitespace characters is considered equal to false in JavaScript.
According to this article, I figured that false would be converted to 0, but was unable to find mention of whitespace considered equal to false using Google.
Why is this? Is there some good reading on the subject besides digging into the ECMAScript spec?
This page provides a good summary of the rules.
Going by those rules, the
'\t\n 'is converted in a number (Number('\t\n') ==> 0), and thefalseis converted into a number (Number(false) ==> 0), and hence the two are equal.Alex’s answer is also a good breakdown of the particular case of
'\t\n ' == false.An important distinction is that
'\t\n 'is not falsy. For example: