RecipesChapter 11: Classes

Choosing the Right Visibility Modifier

Recipe 11.1 from The TypeScript Cookbook

class Person {
  #name;

  constructor(name) {
    this.#name = name;
  }

  get name() {
    return this.#name.toUpperCase();
  }
}
Open in TypeScript Playground →