๐Ÿ“

Class

// __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();
ย 
์ž์„ธํ•œ ๋‚ด์šฉ์€ ์•„๋ž˜ ๋ฌธ์„œ๋ฅผ ์ฐธ๊ณ ํ•ด์ฃผ์„ธ์š”.