TypeScript · Junior · Question 56 of 75

What does if (count) miss when count: number | undefined?

Explanation

Truthiness narrowing treats 0, '' and NaN as false. Use count !== undefined when zero is meaningful.

Further reading

Problem with a question

TypeScript · Junior · question 56

Test yourself

Take the TypeScript · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz