TypeScript · Junior · Question 56 of 75
What does if (count) miss when count: number | undefined?
- ✓Correct answer: It also excludes
0, which may be a valid value - 2Nothing - it only excludes
undefined - 3It excludes negative numbers
Explanation
Truthiness narrowing treats 0, '' and NaN as false. Use count !== undefined when zero is meaningful.