I found this somewhere: Instead of if (count != undefined && count != null), use if(count != null). Can I use if (count == null) and if(!count) interchangeably?
Asked
Active
Viewed 747 times
-3
Prashant
- 3,273
- 3
- 22
- 39
-
1`count != undefined && count != null` is *exactly* the same as `count != null`. `!count` is true if `count` is `null`, `undefined`, `0`, `NaN`, the empty string, or `false`. (Converted to an answer while I look for a duplicate) – Ry- Aug 18 '16 at 09:44
-
https://dorey.github.io/JavaScript-Equality-Table/ – Etheryte Aug 18 '16 at 09:44
1 Answers
5
count != undefined && count != null is exactly the same as count != null. !count is true if count is null, undefined, 0, NaN, the empty string, or false.
Ry-
- 209,133
- 54
- 439
- 449