CodeZettaInterview Hub

TypeScript · Interfaces · Junior · Comparison

Optional vs readonly properties?

Short Interview Answer

?: may be absent; readonly prevents reassignment of the property.

Detailed Explanation

readonly is shallow. Optional undefined vs missing differs under exactOptionalPropertyTypes.

Did you know this answer?