Skip to content
Open
Next Next commit
[충돌해결] Part1 9.3 class extends Object 과제 해설 정리
  • Loading branch information
NterChoi committed May 16, 2026
commit 4e13f8dbef600f25689f79452bbb10b6555c66ab
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
먼저, 해당 코드가 왜 작동하지 않는지 살펴봐야 합니다.

코드를 실행하면 이유를 찾을 수 있습니다. 상속 받는 클래스의 생성자는 `super()`를 반드시 호출해야 합니다. 그렇지 않으면 `"this"`가 '정의'되지 않습니다.
코드를 실행하면 이유를 찾을 수 있습니다. 상속받는 클래스의 생성자는 `super()`를 반드시 호출해야 합니다. 그렇지 않으면 `"this"`가 '정의'되지 않습니다.

수정한 코드는 다음과 같습니다.

Expand All @@ -21,22 +21,14 @@ alert( rabbit.hasOwnProperty('name') ); // true

그런데 이게 끝이 아닙니다.

<<<<<<< HEAD
위와 같이 수정 해도, 여전히 `"class Rabbit extends Object"`와 `class Rabbit`는 다른점이 있습니다.
=======
Even after the fix, there's still an important difference between `"class Rabbit extends Object"` and `class Rabbit`.
>>>>>>> upstream/master
위와 같이 수정해도, 여전히 `"class Rabbit extends Object"`와 `class Rabbit` 사이에는 중요한 차이가 있습니다.

아시다시피 'extends' 문법은 두 개의 프로토타입을 설정합니다.

1. 생성자 함수의 `"prototype"` 사이(일반 메서드용)
2. 생성자 함수 자체 사이(정적 메서드용)

<<<<<<< HEAD
예시의 `class Rabbit extends Object`는 다음과 같은 관계를 만들죠.
=======
In the case of `class Rabbit extends Object` it means:
>>>>>>> upstream/master
예시의 `class Rabbit extends Object`는 다음과 같은 관계를 만듭니다.

```js run
class Rabbit extends Object {}
Expand All @@ -45,11 +37,7 @@ alert( Rabbit.prototype.__proto__ === Object.prototype ); // (1) true
alert( Rabbit.__proto__ === Object ); // (2) true
```

<<<<<<< HEAD
따라서 `Rabbit`은 아래와 같이 `Rabbit`을 통해 `Object`의 정적 메서드에 접근할 수 있습니다.
=======
So `Rabbit` now provides access to the static methods of `Object` via `Rabbit`, like this:
>>>>>>> upstream/master

```js run
class Rabbit extends Object {}
Expand Down Expand Up @@ -79,11 +67,8 @@ alert ( Rabbit.getOwnPropertyNames({a: 1, b: 2})); // Error

이런 이유 때문에 `Rabbit`에서 `Object`의 정적 메서드를 사용할 수 없습니다.

<<<<<<< HEAD
한편, `Function.prototype`은 `call`, `bind` 등의 '일반' 함수 메서드를 가집니다. 내장 객체, `Object`의 생성자는 `Object.__proto__ === Function.prototype` 관계를 갖기 때문에 `Function.prototype`에 정의된 일반 함수 메서드는 두 경우 모두에 사용할 수 있습니다.
=======
By the way, `Function.prototype` also has "generic" function methods, like `call`, `bind` etc. They are ultimately available in both cases, because for the built-in `Object` constructor, `Object.__proto__ === Function.prototype`.
>>>>>>> upstream/master
한편, `Function.prototype`은 `call`, `bind` 등의 '일반' 함수 메서드를 가집니다. 내장 객체 `Object`의 생성자는 `Object.__proto__ === Function.prototype` 관계를 갖기 때문에 `Function.prototype`에 정의된 일반 함수 메서드는 두 경우 모두에 사용할 수 있습니다.


이해를 돕기 위한 그림:

Expand Down