안녕하세요 선생님
궁금한게 있는데 .한살먹기() 를 할때
class Dog{
constructor(견종, 색){
this.type = 견종;
this.color = 색;
}
}
class Cat extends Dog{
constructor(견종, 색, 나이){
super(견종, 색)
this.age = 나이;
}
nextAge(){
this.age ++
}
}
const 강아지 = new Dog('white', 'brown');
const 고양이 = new Cat('white', 'brown', 5);
고양이.nextAge();
console.log(고양이);
이런식으로 Dog에 if( this instanceof Cat) { this.age++ } 로 넣지않고 적용시킬 Cat에만 넣어줘도 괜찮은건가요??
작동은 잘하는데 혹시 잘 쓰지 않는 방법인가 궁금해요