인프런 커뮤니티 질문&답변
JAVASCRIPT에서 PROTOTYPE과 GETPROTOTYPEOF에 대해서 질문드립니다.
작성
·
248
0
function ParentClass() {};
function ChildClass() {};
ChildClass.prototype = new ParentClass();
var mychild = new ChildClass();
var myparent = new ParentClass();
console.log(mychild);
console.log(myparent);
console.log(mychild.prototype);
console.log(myparent.prototype);
console.log(Object.getPrototypeOf(mychild));
console.log(Object.getPrototypeOf(myparent));
-> 위 예시에서 결과 값은 아래와 같습니다.
ParentClass {}
ParentClass {}
undefined
undefined
ParentClass {}
{}
1) 어떻게 console.log(mychild); 와 console.log(myparent); 의 값이 같게 나올수가 있나요....?
2) console.log(Object.getPrototypeOf(mychild));와 console.log(Object.getPrototypeOf(myparent));
의 결과값이 각각 ChildClass()와 ParentClass();여야 하는거 아닌가요...?
답변
답변을 기다리고 있는 질문이에요
첫번째 답변을 남겨보세요!




