I'm trying to understand DOM API through OOP frame of mind. Since DOM API uses properties and methods that are built into the browser and document
in, say, document.createElement
is an instance of Document
, is it safe to say that document
is an instance created from the Document
constructor? For example, when I'm using DOM, is this what is happening in under the hood?:
let document = new Document();
where Document() is defined as something like:
class Document {
constructor()
//some properties and methods
}
Also, when the following codes are executed:
let link = document.querySelector('a');
link.textContent('This is a link');
is this a case where link
inherits prototype from Document
and the method textContent
is invoked through a setter:
class Document {
set textContent(x){
some_variable = x;
}
}
Is there a way to see the source code of Document
other than console.log(Document)
?