TypeScript · Junior · Question 71 of 75

How does an optional property name?: string differ from name: string | undefined?

Explanation

The difference matters when creating objects: {} is valid for the first type but not for the second.

Further reading

Problem with a question

TypeScript · Junior · question 71

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