Class

const str5 = new info5("μ›Ήμ“°", "웹퍼블리셔");
const str6 = new info5("μ›ΉμŠ€ν† λ¦¬λ³΄μ΄", "ν”„λ‘œκ·Έλž˜λ°");

document.write("7");
info5.study1();
info5.study2();
document.write("<br>");

ν•¨μˆ˜μ˜ 상

class info3 {
            constructor(name, active){
                this.name = name;
                this.active = active;
            }
            study(){
                document.write(this.name + "κ°€" + this.active + "λ˜μ—ˆμŠ΅λ‹ˆλ‹€.");
            }
        }
        const result3 = new info3("ν•¨μˆ˜ 8","μ‹€ν–‰");
        result3.study();

        //클래슀 상속
        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;
            }
            study(){
                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