안녕하세요 저는 자바 스크립트 프로토 타입 체인에서 최상위 수준 (또는 상위 수준의 수준) 프로토 타입을 검색하는 "더 깨끗한"방법이 있는지 궁금합니다.javascript 프로토 타입 체인의 최상위 프로토 타입 검색
var a = Object.create(Object.prototype, {'class' : {value : 'a'}});
var b = Object.create(a, {'class' : {value : 'b'}});
var c = Object.create(b, {'class' : {value : 'c'}});
나는 C에서 얻을 수있는 루프를 작성하지 않고 :
문제
주어진 것입니다?var topClass = c;
while (Object.getPrototypeOf(topClass) !== Object.prototype) {
topClass = Object.getPrototypeOf(topClass);
}
console.log('expect this to be true: '+ a === topClass);
@ tj- crowder 그걸 몰랐어! – Renaud