클래스

클래스 상속

class Box1 {
    constructor(name, active){
        this.name = name;
        this.active = active;
    }
    study(){
        document.write(this.name+"가"+this.active+"되었습니다.");
    }
}
class Box2 extends Box1 {
    constructor(name, active, today){
        super(name, active);
        this.today = today;
    }
    study2(){
        document.write(this.today + this.name+"가"+this.active+"되었습니다.");
    }
}
const result4 = new Box1("함수9","실행");
const result5 = new Box2("함수10","실행","오늘도");
result4.study();
result5.study();
result5.study2();

Last updated

Was this helpful?