Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
392 B
1
Indexable
Never
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
//