# Typescript - Tips & Tricks - Optional modifier > Hi guys and welcome back, Today I'll talk about the optional modifier. Sometimes we have objects that... - **Author**: Luca Del Puppo (@puppo92) — AI Native Engineer at Nearform - **Published**: Mar 3, 2021 - **Canonical URL**: https://delpuppo.net/blog/ts-tips-and-tricks/typescript-tips-tricks-optional-modifier/ - **Series**: TypeScript - Tips & Tricks (Part 8 of 21) — https://delpuppo.net/blog/series/ts-tips-and-tricks/ - **Series LLMs.txt**: https://delpuppo.net/blog/series/ts-tips-and-tricks/llms.txt - **Category**: TypeScript - **Tags**: typescript, webdev - **Hashnode Mirror**: https://blog.delpuppo.net/typescript-tips-tricks-optional-modifier - **Dev.to Mirror**: https://dev.to/playfulprogramming/typescript-tips-tricks-optional-modifier-48pg - **Blog Index LLMs.txt**: https://delpuppo.net/blog/llms.txt ## Series Context: TypeScript - Tips & Tricks - Part 1: [Typescript - Tips & Tricks - typeof](https://delpuppo.net/blog/ts-tips-and-tricks/typescript-tips-tricks-typeof/) - Part 2: [Typescript - Tips & Tricks - Literal Types](https://delpuppo.net/blog/ts-tips-and-tricks/typescript-tips-tricks-literal-types/) - Part 3: [Typescript - Tips & Tricks - keyof](https://delpuppo.net/blog/ts-tips-and-tricks/typescript-tips-tricks-keyof/) - Part 4: [Typescript - Tips & Tricks - Union and Intersection](https://delpuppo.net/blog/ts-tips-and-tricks/typescript-tips-tricks-union-and-intersection/) - Part 5: [Typescript - Tips & Tricks - Overloaded Functions](https://delpuppo.net/blog/ts-tips-and-tricks/typescript-tips-tricks-overloaded-functions/) - Part 6: [Typescript - Tips & Tricks - this parameter](https://delpuppo.net/blog/ts-tips-and-tricks/typescript-tips-tricks-this-parameter/) - Part 7: [Typescript - Tips & Tricks - any vs. unknown](https://delpuppo.net/blog/ts-tips-and-tricks/typescript-tips-tricks-any-vs-unknown/) - Part 8: [Typescript - Tips & Tricks - Optional modifier](https://delpuppo.net/blog/ts-tips-and-tricks/typescript-tips-tricks-optional-modifier/) **(Current Article)** - Part 9: [Typescript - Tips & Tricks - Index Signature](https://delpuppo.net/blog/ts-tips-and-tricks/typescript-tips-tricks-index-signature/) - Part 10: [Typescript - Tips & Tricks - readonly modifier](https://delpuppo.net/blog/ts-tips-and-tricks/typescript-tips-tricks-readonly-modifier/) - Part 11: [Typescript - Tips & Tricks - Readonly Array](https://delpuppo.net/blog/ts-tips-and-tricks/typescript-tips-tricks-readonly-array/) - Part 12: [Typescript - Tips & Tricks - Tuple](https://delpuppo.net/blog/ts-tips-and-tricks/typescript-tips-tricks-tuple/) - Part 13: [Typescript - Tips & Tricks - Non-null assertion operator](https://delpuppo.net/blog/ts-tips-and-tricks/typescript-tips-tricks-non-null-assertion-operator/) - Part 14: [Typescript - Tips & Tricks - Never type](https://delpuppo.net/blog/ts-tips-and-tricks/typescript-tips-tricks-never-type/) - Part 15: [Typescript - Tips & Tricks - Assert Function](https://delpuppo.net/blog/ts-tips-and-tricks/typescript-tips-tricks-assert-function/) - Part 16: [Typescript - Tips & Tricks - Type Guard](https://delpuppo.net/blog/ts-tips-and-tricks/typescript-tips-tricks-type-guard/) - Part 17: [Typescript - Tips & Tricks - Conditional Type](https://delpuppo.net/blog/ts-tips-and-tricks/typescript-tips-tricks-conditional-type/) - Part 18: [Typescript - Tips & Tricks - infer keyword](https://delpuppo.net/blog/ts-tips-and-tricks/typescript-tips-tricks-infer-keyword/) - Part 19: [Typescript - Tips & Tricks - Mapped Types](https://delpuppo.net/blog/ts-tips-and-tricks/typescript-tips-tricks-mapped-types/) - Part 20: [Typescript - Tips & Tricks - Advanced Types](https://delpuppo.net/blog/ts-tips-and-tricks/typescript-tips-tricks-advanced-types/) - Part 21: [Typescript - Tips & Tricks - Rest Parameters & Rest Arguments](https://delpuppo.net/blog/ts-tips-and-tricks/typescript-tips-tricks-rest-parameters-rest-arguments/) --- Hi guys and welcome back, Today I'll talk about the optional modifier. Sometimes we have objects that have some optional properties. In these cases, we need to identify the optional and the required properties, so the consumers can know what is required and what not. To do this in typescript we have a special modifier named "optional" and it is identified by a question mark (_?_). Let's see an example: ```ts export type Person = { name: string; surname: string; email: string; phone?: string; }; const person1: Person = { name: "name1", surname: "surname1", email: "email1@email1.it", }; const person2: Person = { name: "name2", surname: "surname2", email: "email2@email2.it", phone: "123", }; ``` In this example we can see the optional modifier in action, the "phone" property is marked as optional so in the "person1" object we can avoid setting the "phone" property. This modifier, also, could be used in the functions' parameters if we have one or more optional parameters. A simple example. ```ts function printPerson(name: string, email: string, phone?: string): void { console.log(`Name: ${name}`); console.log(`Email: ${email}`); if (phone) console.log(`Phone: ${phone}`); } printPerson("name1", "email1@email1.it"); /* Name: name1 Email: email1@email1.it */ printPerson("name2", "email2@email1.it", "123"); /* Name: name2 Email: email2@email1.it Phone: 123 */ ``` We can see how in the first example we can avoid setting the phone parameter because it's optional. From the optional modifier, it's all. See you soon guy!