Untitled

 avatar
unknown
plain_text
3 years ago
392 B
3
Indexable
export class User {
  private name: string;
  private age: number;

  setName(name: string) {
    this.name = name;
    return this;
  }

  setAge(age: number) {
    this.age = age;
  }

  display() {
    console.log('name: ', this.name, ', age: ', this.age)
  }
}

const john = new User();
//
john.setName('John').setAge(29)
john.display() // -> name: John age: 29
//
Editor is loading...