IT
typescript readonly 활용 예시
agnusdei1207
2023. 5. 24. 12:48
반응형
SMALL
class Car{
#privat:number = 30;
protected protect:string = "protected";
readonly name:string = "Car"; // readonly 수정 불가능
// color:string;
constructor(public readonly color:string, name:string){
this.color = color;
this.name = name; // readonly 수정할 수 있도록 생성자에서 처리
}
start(){
console.log("start");
console.log(this.#privat); // private
}
}
반응형
LIST