0
저는 TS 생성자로 고민하고 있습니다. 나도이 stackoverflow에 게시하십시오.여러 타이프 스크립트 생성자
public Animal(){
this.name = “default”;
this.noise =””;
public Animal(string name){
this.name = name;
this.noise = “”;
}
public Animal(string name, string noise){
this.name = name;
this.noise = noise;
}
당신이 타이프에서이 같은 일을 수행
는이 세 가지 생성자에 해당하게하고 싶은 말은?Constructor(name?:string, noise?:string){
if(name!= null)
this.name =name;
else
this.name = "";
if(string != null)
this.noise = noise;
else
this.noise = "";
}
등등?
int 또는 string으로 동물을 선언 할 수있는 다양한 프리미티브가 있다면 어떻할까요? instanceof를 사용하고 있습니까?
감사합니다. 이 매우 간단하게 수행 할 수 있습니다