Javascript document.body与document.prototype.body
自 返回true和sinceJavascript document.body与document.prototype.body,javascript,prototype,Javascript,Prototype,自 返回true和since document.__proto__.__proto__===Document.prototype 也返回true 有人能给我解释一下为什么document.body和document.prototype.body不是一回事吗?此外,为什么Chrome开发者工具中的Document.prototype.body会导致 Document.prototype.hasOwnProperty('body') 而document.body的结果是 Uncaught Typ
document.__proto__.__proto__===Document.prototype
也返回true
有人能给我解释一下为什么document.body和document.prototype.body不是一回事吗?此外,为什么Chrome开发者工具中的Document.prototype.body会导致
Document.prototype.hasOwnProperty('body')
而document.body的结果是
Uncaught TypeError: Illegal invocation(…)
(anonymous function) @ VM6098:2
InjectedScript._evaluateOn @ VM3911:904
InjectedScript._evaluateAndWrap @ VM3911:837
InjectedScript.evaluate @ VM3911:693
。。。
文档。prototype
是文档的类型(prototype..)。\uu proto\uuu
,但这并不意味着它是同一个对象。通过继承,在对象的原型链中查找未作为对象属性找到的属性。对于document.body
,它来自document.prototype.body
,因此让我们看看该属性:
console.log(Object.getOwnPropertyDescriptor(Document.prototype,'body'))
<body...>...</body>