Angular: Shorthand for defining a Class’s properties

Consider the property ‘name’ in the following class:

class Necklace {
  private name: string;
  constructor (name: string) {
    this.name = name;
  }
}

Here, the property ‘name’ with private visibility is initialized via the constructor. You can accomplish the same thing using less code:

class Necklace {
  constructor (private name: string) {}
}