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

Was this helpful?