// __proto__ (๋น๊ณต์) ๋ฌธ๋ฒ์ด์์. // prototype ๊ณต์์ ๋๋ค. // __proto__๋ [[Prototype]]์ getterยทsetter // getter๋? // setter๋? class Human { constructor(name) { this.hp = 100; this.mp = 100; this.speed = 0; this.name = name; } attack(speed) { this.speed = speed; console.log(`${this.name}์ด ${this.speed}์ ์๋๋ก ๊ณต๊ฒฉํฉ๋๋ค.`); } stop() { this.speed = 0; console.log(`${this.name}์ด ๊ณต๊ฒฉ์ ๋ฉ์ท์ต๋๋ค.`); } } let ์์ ์ฃผ์ธ = new Human("์ดํธ์ค"); let ๋์ฅ์ฅ์ด = new Human("ํ๊ธธ๋"); class Hero extends Human{ skill() { console.log(`${this.name}๊ฐ ์คํฌ์ ์ฌ์ฉํ์ต๋๋ค!`); } stop() { super.stop(); // ๋ถ๋ชจ ํด๋์ค์ stop์ ํธ์ถํด ๋ฉ์ถ๊ณ this.skill(); // skill ์ฌ์ฉ } } let ์์ = new Hero("์ดํธ์ค"); ์์ .attack(5); ์์ .stop();
ย
์์ธํ ๋ด์ฉ์ ์๋ ๋ฌธ์๋ฅผ ์ฐธ๊ณ ํด์ฃผ์ธ์.