강의

멘토링

커뮤니티

Inflearn Community Q&A

rhkdtjd124829's profile image
rhkdtjd124829

asked

Advanced Modern Javascript with ES6 Grammar Part 1

Constructor functions and the operations handled internally

완벽한 이해를 한게 맞는지 질문드려용

Written on

·

188

0

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

const p1 = new Person("juu", 20);
console.log(p1);

                                                    최상위레벨의 객체(Object원형) Object원형보다 최상위를 가리킴 -> null
                                                    +hasOwnProperty등 object원형에 있는 함수들이 있음.


Person 함수                                                             Person 프로토타입 객체 -> Object원형을 가리킴
+ prototype --> Person 프로토타입 객체(참조)                                + constructor --> Animal 함수(참조)
+ new를 통해서 p1객체나 p2객체를 생성                                    

 p1객체
 + prototype --> 원형인 Person 프로토타입 객체를 참조

 p2객체
 + prototype --> 원형인 Person 프로토타입 객체를 참조

console.log해설
▼ Person {name : "juu", age: 20}             --> Person 생성자함수
  age: 20                                    --> Person 함수의 멤버 age
  name: "juu"                                --> Person 함수의 멤버 name
  ▼ [[Prototype]]: Object                    --> p1객체의 프로토타입 객체
     ► constructor: f Person(name,age)       --> Person 프로토타입 객체 -> constructor로 Person 함수 참조
     ► [[Prototype]]: Object                 --> Person 프로토타입 객체 조차도 Prototype을 가짐 -> 최상위레벨의 객체(Object원형) 참조
                                             --> 최상위레벨의 객체(Object원형)도 더 최상위를 가리키는데 -> null
es6javascript

Answer

This question is waiting for answers
Be the first to answer!
rhkdtjd124829's profile image
rhkdtjd124829

asked

Ask a question