function Person(){}
완전히 같다
let Person = function();
자바스크립트의 함수들은 객체기 때문에 프로퍼티를 가질 수 있다.
class Person{
constructor(name,first,second){
this.name = name
this.first = first
this.second = second
}
sum() {
return this.first +this.second;
}
}
class PersonPlus extends Person{
constructor(name,first,second,third) {
super(name, first, second)
this.third = third
}
sum() {
return super.sum() + this.third;
}
avg() {
return (this.first +this.second+this.third) /3
}
}
let kim = new PersonPlus('kim',10,20,30)
console.log(kim.sum())
class 를 만들고 그 안에 생성자를 만들고 메서드를 넣는다.