2020. 10. 1. 23:06, Developer
class Person{
constructor(private _name:string, private _age:number){
}
hello():void {
console.log(this._name);
}
getName():string{
return this._name;
}
setName(name:string){
this._name=name;
}
}
const person : Person = new Person('kim',30);
console.log(person.getName());
person.setName('aaaa');
console.log(person.getName());
'Developer' 카테고리의 다른 글
[typescript]Generic (0) | 2020.10.02 |
---|---|
[typescript]class - readonly (0) | 2020.10.01 |
[typescript]class - 자식 생성자는 super를 꼭 가져야함 (0) | 2020.10.01 |
[typescript]class - class안에 생성자의 private 변수 (0) | 2020.10.01 |
[typescript]class - protected (0) | 2020.10.01 |
Comments, Trackbacks