인프런 커뮤니티 질문&답변
완벽한 이해를 한게 맞는지 질문드려용
작성
·
177
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답변
답변을 기다리고 있는 질문이에요
첫번째 답변을 남겨보세요!





