오늘 줌 라이브 세션을 들으면서 그냥 넘어갔던 부분을 다시 짚고 넘어가고자 한다.
class Human {
constructor(){
this.age=30;
this.food='jelly';
}
constructor
에 아무것도 넣지 않을 경우 constructor
내부에서 직접 속성 및 값을 설정해 줄 수 있다.
class Human {
constructor(age,food){
this.age=age;
this.food=food;
}
이번에는 constructor
에 인자들을 넣었을 경우인데, default 값으로 미리 설정할 수도 있다.
참고로 constructor
에 아무것도 추가하지 않아도
이런식으로 기본 constructor
가 생성이 된다.