⊗jstsPmDSOP 41 of 55 menu

Optional Object Properties in TypeScript

When declaring an object, you can specify some properties as optional. To do this, you need to specify a question mark after the property name.

For example, let's make the 'age' property optional in the user object:

let user: {name: string, age?: number};

Now we can write to a variable an object with only one property 'name':

user = {name: 'john'};

Or we can write an object that has both the 'name' property and the 'age' property:

user = {name: 'john', age: 30};

Without running the code, determine what the result of executing the code will be:

let date = {year: number, month: number, day?: number}; date = {year: 2025, month: 12};
enru