conventions.io

Tech Challenge

2026-05-24

🔷

Daily Tech Challenge

TypeScript

medium
Question 1 of 5

What does the `readonly` modifier do when applied to a class property in TypeScript?

Example
class Point {
  readonly x: number;
  readonly y: number;

  constructor(x: number, y: number) {
    this.x = x;
    this.y = y;
  }

  move(dx: number) {
    this.x = this.x + dx; // Error here
  }
}

Sunday, May 24, 2026 · A new challenge drops every day