TypeScript · Junior · Question 9 of 75
What does the type string | number mean?
- ✓Correct answer: The value can be a string or a number (a union)
- 2The value is both a string and a number at once (an intersection)
- 3A string that contains only digits
Explanation
A union type allows any of its members. Until the type is narrowed, only operations common to all members are available. An intersection is written with & and requires matching all types at once (A & B).