Practice question from Advanced Typescript

What does the readonly modifier do in this interface? A. Prevents reassignment of entire object B. Makes properties unchangeable after initialization C. Allows only reading properties D. Creates a constant object E. Prevents adding new properties

interface Config {
  readonly apiKey: string;
  readonly endpoints: string[];
}

Answer

B

Explanation

The readonly modifier prevents modification of individual properties after initial assignment

More questions from Quick: Advanced Typescript