检测属性存在于哪些原型对象中,其原型链追溯至何方?
- 内容介绍
- 文章标签
- 相关推荐
本文共计48个文字,预计阅读时间需要1分钟。
javascriptfunction getPrototypeOfChain(object, property) { var arr=[]; while (object) { if (object.hasOwnProperty(property)) { arr.push(object); } object=Object.getPrototypeOf(object); } console.dir(arr);}
function protoProperty(object,property){ var arr = []; while(object){ if(object.hasOwnProperty(property)){ arr.push(object); } object=object.__proto__; } console.dir(arr); }
本文共计48个文字,预计阅读时间需要1分钟。
javascriptfunction getPrototypeOfChain(object, property) { var arr=[]; while (object) { if (object.hasOwnProperty(property)) { arr.push(object); } object=Object.getPrototypeOf(object); } console.dir(arr);}
function protoProperty(object,property){ var arr = []; while(object){ if(object.hasOwnProperty(property)){ arr.push(object); } object=object.__proto__; } console.dir(arr); }

