Search code examples
javascripthtmlhtmldoc

What is the HTMLDocument function?


I have noticed that if you write a program like this:

console.log(document);

It shows [object HTMLDocument]. Then, if you do this:

console.log(HTMLDocument);

it shows this:

function HTMLDocument() {
   [native code]
}

So, I am wondering what the HTMLDocument function is, and what its code is. Thanks!


Solution

  • This is the constructor of the HTMLDocument object.

    Documentation:

    The HTMLDocument interface, which may be accessed through the Window.HTMLDocument property, extends the Window.HTMLDocument property to include methods and properties that are specific to HTML documents.

    Native code is a core functionality offered by the browser rather than a code written in Javascript.