JAVASCRIPT/자바스크립트
JS. 클래스 상속
(*ᴗ͈ˬᴗ͈)ꕤ*.゚
2022. 4. 15. 10:49
{
class study {
constructor(num, name, job){
this.num = num;
this.name = name;
this.job = job;
}
result(){
document.write(this.num + ".내 이름은 " + this.name + "이며, 직업은 " + this.job + "입니다.");
}
}
class study2 extends study {
constructor(num, name, job, age){
super(num, name, job);
this.age = age;
}
result2(){
document.write(this.num + ".내 이름은 " + this.name + "이며, 직업은 " + this.job + "입니다. 나이는 " + this.age + "세 입니다.");
}
}
const info1 = new study(1, "웹쓰", "웹퍼블리셔");
const info2 = new study2(2, "웹스토리보이", "프론트엔드개발자", "20");
info1.result();
info2.result2();
}