Untitled
Anonymous
plain_text
11/29/2022 9:57 AM
524 B
18
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...