[JavaScript] ํด๋์ค ES6
ES6๋ถํฐ ํด๋์ค ๋ฌธ๋ฒ์ด ์๊ฒผ๋ค.
๊ทผ๋ฐ ๋ญ ์ฌ์ค ๋๋จํ ๊ธฐ๋ฅ์ด ์ถ๊ฐ๋๊ฑด ์๋๊ณ , ๋จ์ํ ํธ์์ฑ๊ณผ ๊ฐ๋ ์ฑ์ ์ํด ์ถ๊ฐ๋๊ฑฐ๋ผ๊ณ ํ๋ค.
๋์ถฉ ์ด๋ ๊ฒ ์๊ฒผ๋ค.

class Person {
//์์ฑ์๋ค.
constructor(name, age){
this._name = name;
this._age = age
}
//์ฝ๊ธฐ์ ์ฉ ํ๋กํผํฐ๋ค.
get Name() {
return this._name;
}
//์ฐ๊ธฐ์ ์ฉ ํ๋กํผํฐ๋ค.
set Name(name) {
this._name = name;
}
get Age(){
return this._age;
}
//๊ทธ๋ฅ ๋ฉ์๋๋ค.
AgeInc(){
this._age++;
}
}
var john = new Person('john', '3000');
john.Name='tom';
john.AgeInc()
console.log(john.Name, john.Age);์์๋ ์ข๋ ๋ณด๊ธฐ ์ข๊ฒ ์ ๊ณต๋๋ค.
์ ๊ทผ์ ์ด๋ ์ ๋๋ ๊ฒ ๊ฐ๋ค๋ง..

//Person์ ์์๋ฐ๋ Student ํด๋์ค
class Student extends Person
{
constructor(name, age, school){
super(name, age); //์์ ํด๋์ค ์ด๊ธฐํ
this._school = school;
}
get School() {
return this._school;
}
}
var john = new Student('john', '3000', 'ํธ๊ทธ์ํธ');
console.log(john.Name, john.Age, john.School);