[TIL - 2022.7.25 객체지향 추가 내용]

Jeong Ha Seung·2022년 7월 25일
0

부트캠프

목록 보기
21/51

오늘 줌 라이브 세션을 들으면서 그냥 넘어갔던 부분을 다시 짚고 넘어가고자 한다.

오늘 공부한 내용

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 가 생성이 된다.

profile
블로그 이전했습니다. https://nextjs-blog-haseungdev.vercel.app/

0개의 댓글