yuzunsang / JS-deep-dive-study

자바스크립트 딥 다이브 스터디✨
0 stars 3 forks source link

[CH25]클래스 #41

Open yuzunsang opened 2 months ago

yuzunsang commented 2 months ago

[퀴즈 예시] Q. 여기에 퀴즈 설명을 적으세요.

적을 코드가 있다면 밑에 적어주세요. (백틱 3개로 코드를 감싸면 코드 양식을 적을 수 있습니다.)

// 예시 코드
const arr = [1, 2, 3];
console.log("Hello");

아래 코드를 복붙해서 정답을 적어주세요.

<details>
    <summary>정답</summary>
    <div markdown="1">    
    정답 설명
    </div>
</details>
yuzunsang commented 2 months ago

Q. 다음의 실행 결과가 나오도록 빈칸을 채워주세요.

[실행 결과] 유준상이(가) 와르르맨션의 201호를 계약했습니다. 5 명이 계약 대기중입니다.

class 부동산 {
   [빈칸 1](맨션) {
        this.맨션 = 맨션;
    }
}

class 전세 [빈칸 2] 부동산 {
    [빈칸 1](맨션, 세입자, 호수) {
        [빈칸 3](맨션);
        this.세입자 = 세입자;
        this.호수 = 호수;
    }

    계약정보() {
        console.log(`${this.세입자}이(가) ${this.맨션}의 ${this.호수}호를 계약했습니다.`);
    }

    [빈칸 4] 계약대기(대기자) {
        console.log(`${대기자} 명이 계약 대기중입니다.`);
    }
}

const user = new 전세("와르르맨션", "유준상", 201);
user.계약정보();

전세.계약대기(5);
정답
[빈칸 1] : constructor
[빈칸 2] : extends
[빈칸 3] : super
[빈칸 4] : static
J-yun-ji commented 2 months ago

Q. 아래의 빈칸을 채우세요.

(1)와 (2)는 자신이 속해 있는 프로토타입 체인이 다르다. (2)는 인스턴스 프로퍼티를 참조할 수 있지만 (1)는 인스턴스 프로퍼티를 참조할 수 없다. (1)는 클래스로 호출하고 (2)는 (3)로 호출한다.

정답
(1) 정적 메서드
(2) 프로토타입 메서드
(3) 인스턴스
bo-eun commented 2 months ago

Q. 아래 콘솔로그 결과를 예측해보세요.

class Person {
  constructor(name, age) {
    this.name = name;
    this.age = age;
  }

  greet() {
    console.log(`Hello1`);
  }

  static greet() {
    console.log('Hello2');
  }
}

const boeun = Person('boeun', 26);
console.log(boeun.greet());
정답
'Hello1'