TypeScript · Junior · Question 71 of 75
How does an optional property name?: string differ from name: string | undefined?
- ✓Correct answer: With
?the property may be omitted entirely; with| undefinedit must be present, even if its value isundefined - 2They are completely identical
- 3
?makes the propertynull
Explanation
The difference matters when creating objects: {} is valid for the first type but not for the second.