01 / 06
Put ? on something that might not be there
Real data has fields that some people have and others do not — a nickname that some have registered and some have not.
For a property like that, put a ? after the name. It means you do not have to write this one.
interface Person { name: string; nickname?: string;}const yui: Person = { name: "Yui" };console.log(yui);Result
{ name: "Yui" }