This is the image of the index on the left on Mozilla Developer Network.
What I would like to ask is this:
What is the difference between Document
and document
?
The reason why I am asking is this:
I have always retrieved elements as follows (document
with a small d
):
document.getElementById("#id");
and MDN lists it as follows (Document
with a capital D
) :
Document.getElementById("#id");
document is the actual object for your html page loaded in browser. This is a DOM object.
Document is the function(a DOM interface precisely), which will be used to create the document object. This "Document" is implemented by the browser program. This takes our HTML file as input and creates the "document" object.
Document.getElementById(..) -> wrong. This wont work.
Document.prototype.getElementById(..) This is the right way
Refer this link - Reference link Document Implementation is specific to each browser. But it can be extended. Check this article too. http://perfectionkills.com/whats-wrong-with-extending-the-dom/
The document object could be from separate implementations by browsers based on the file type. For HTML the prototype would be "HTMLDocumentPrototype" (uses Document interface), and for XML it would be just a "Object" and no prototype attached. This might differ from browser to browser, since implementation is specific.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With