Skip to content

Commit

Permalink
2023-05-22 [Javasript] Object Prototype Update
Browse files Browse the repository at this point in the history
  • Loading branch information
gyoogle authored May 22, 2023
1 parent 241e11b commit 1c4bc8f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Language/[Javasript] Object Prototype.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Prototype은 JavaScript object가 다른 object에서 상속하는 매커니즘이다.

## A prototype-based language?
JavaScript는 종종 prototype-based language로 설명된다. prototype-based language는 상속을 지원하고 object는 prototype object를 갖는다. prototyp object는 method와 property를 상속하는 template object 같은 것이다.
JavaScript는 종종 prototype-based language로 설명된다. prototype-based language는 상속을 지원하고 object는 prototype object를 갖는다. prototype object는 method와 property를 상속하는 template object 같은 것이다.

object의 prototype object 또한 prototype object를 가지고 있으며 이것을 **prototype chain** 이라고 부른다.

Expand All @@ -23,7 +23,7 @@ function Person(first, last, age, gender, interests) {
//...see link in summary above for full definition
}
```
우리는 object instace를 아래와 같이 만들 수 있다.
우리는 object instance를 아래와 같이 만들 수 있다.
```js
let person1 = new Person('Bob', 'Smith', 32, 'male', ['music', 'skiing']);
```
Expand All @@ -34,4 +34,4 @@ person1.valueOf()
```
valueOf()를 호출하면
- 브라우저는 person1 object가 valueOf() method를 가졌는지 확인한다. 즉, 생성자인 Person()에 정의되어 있는지 확인한다.
- 그렇지 않다면 person1의 prototype object를 확인한다. prototype object에 method가 없다면 prototype object의 prototype object를 확인하며 prototype object가 null이 될 때까지 탐색한다.
- 그렇지 않다면 person1의 prototype object를 확인한다. prototype object에 method가 없다면 prototype object의 prototype object를 확인하며 prototype object가 null이 될 때까지 탐색한다.

0 comments on commit 1c4bc8f

Please sign in to comment.