Skip to content

Commit 4e13f8d

Browse files
committed
[충돌해결] Part1 9.3 class extends Object 과제 해설 정리
1 parent 71ab899 commit 4e13f8d

1 file changed

Lines changed: 5 additions & 20 deletions

File tree

  • 1-js/09-classes/03-static-properties-methods/3-class-extend-object

1-js/09-classes/03-static-properties-methods/3-class-extend-object/solution.md

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
먼저, 해당 코드가 왜 작동하지 않는지 살펴봐야 합니다.
22

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

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

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

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

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

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

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

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

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

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

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

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

82-
<<<<<<< HEAD
83-
한편, `Function.prototype``call`, `bind` 등의 '일반' 함수 메서드를 가집니다. 내장 객체, `Object`의 생성자는 `Object.__proto__ === Function.prototype` 관계를 갖기 때문에 `Function.prototype`에 정의된 일반 함수 메서드는 두 경우 모두에 사용할 수 있습니다.
84-
=======
85-
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`.
86-
>>>>>>> upstream/master
70+
한편, `Function.prototype``call`, `bind` 등의 '일반' 함수 메서드를 가집니다. 내장 객체 `Object`의 생성자는 `Object.__proto__ === Function.prototype` 관계를 갖기 때문에 `Function.prototype`에 정의된 일반 함수 메서드는 두 경우 모두에 사용할 수 있습니다.
71+
8772

8873
이해를 돕기 위한 그림:
8974

0 commit comments

Comments
 (0)