Skip to content

Window vs. Document

What Is the Difference Between window and document?

WindowDocument
It is the root-level element in any web page.It is the direct child of the window object. This is also known as the Document Object Model (DOM).
By default, the window object is available implicitly on the page.You can access it via window.document or document.
It has methods such as alert() and confirm(), and properties such as document and location.It provides methods such as getElementById, getElementsByTagName, and createElement.