I was wondering when the Javascript if
expression actually evaluates to false
and when to true
. When is the if
statement false
, and is that true for all JS interpreters?
I guess the condition is false
on
false
undefined
null
0
otherwise true
. Is that correct for all implementations (tested in Safari/WebKit console), or am I better off with explicit checking like (typeof a === "undefined")
?
The following values will evaluate to false:
https://developer.mozilla.org/en/JavaScript/Guide/Statements#if...else_Statement
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