Document.body vs Document.prototype.body

Because

document.__proto__.__proto__===Document.prototype

returns true, and since

Document.prototype.hasOwnProperty('body')

also returns true

can someone explain to me why document.body and Document.prototype.body are not the same thing? Moreover, why Document.prototype.body inside the Chrome developer tools leads to

Uncaught TypeError: Illegal invocation(โ€ฆ)
(anonymous function) @ VM6098:2
InjectedScript._evaluateOn @ VM3911:904
InjectedScript._evaluateAndWrap @ VM3911:837
InjectedScript.evaluate @ VM3911:693

whereas document.body results

<body...>...</body>
+4
source share
1 answer

Document.prototype - (..) document.__proto__, , . , , . document.body, Document.prototype.body, :

console.log(Object.getOwnPropertyDescriptor(Document.prototype, 'body'))
Hide result

, body , . , Document.prototype.body - .

this , document:

console.log(Object.getOwnPropertyDescriptor(Document.prototype, 'body').get.call(document))
Hide result

, -.

+2

Source: https://habr.com/ru/post/1609448/


All Articles