I understand that an empty string is falsy in javascript and a not-empty string is truthy in javascript.
However, why is 'false'
truthy in javascript, is there anything explicit in the specification? Is it a performance issue or are there situations where you would want the string 'false'
to represent true
?
is there anything explicit in the specification?
Yes:
The result is false if the argument is the empty String (its length is zero); otherwise the result is true.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With