Q11. What does readonly guarantee?

readonly prevents reassignment through the typed reference. It does not deep-freeze nested objects at runtime, and another mutable alias may still change the same underlying object. Use runtime immutability mechanisms if runtime enforcement is required.

A readonly property is a compile-time assignment restriction, not a security boundary or deep freeze.

Note

Interview approach: define the concept, explain why it matters, then mention one trade-off or limitation.

TypeScript concept
// Illustrative TypeScript contract
type Identifier = string;
const id: Identifier = "item-1";
💡 The example demonstrates the compile-time contract discussed in this question.
Key Takeaways
  • Explain the concept in your own words.
  • Know the practical trade-off and its limits.
  • Use a small example to demonstrate the idea.
Knowledge Check

Does `readonly` automatically freeze an object at runtime?