What is the purpose of the `readonly` modifier in TypeScript?

TypeScript Associate Easy

TypeScript Associate — Easy

What is the purpose of the `readonly` modifier in TypeScript?

Key points

  • `readonly` restricts property assignment after initialization
  • Helps maintain immutability in code
  • Different from preventing property access or making it optional

Ready to go further?

Related questions