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?