TypeScript · Junior · Question 52 of 75
How does (string | number)[] differ from string[] | number[]?
- ✓Correct answer: The first is one array that may mix strings and numbers; the second is either an all-strings or an all-numbers array
- 2They are the same
- 3The second allows mixing, the first doesn't
Explanation
Parentheses matter: string | number[] would mean "a string or an array of numbers".