In the same way you might see someone referencing Array.find
(when in fact .find
only exists on Array.prototype
), .write
exists on the prototype of Document, not on the Document constructor itself.
console.log(Document.prototype.hasOwnProperty('write'));
document.write
works because document
inherits from Document.prototype
.
MDN's usage of Document.write
is meant to convey that .write
can be called on any instance of Document
, even though the document constructor itself doesn't have that property.
It's possible to call .write
from the prototype, if you wanted:
Document.prototype.write.call(
document, // call on *this HTML document*
'<div>foobar</div>' // first argument passed to .write
);