Optional – typescript

ref – https://www.becomebetterprogrammer.com/typescript-question-mark/

A property can either have a value based on the type:
defined
or
undefined

A key difference here:

When using optional, the property is literally optional. We don’t even need to declare it.

If we were to do use value | undefined, the value may either exist or be undefined, but we MUST make sure the property is there:

Example Usage:

say if we declare null for Test’s datq property: