Example 1 — Basic Read
Beginner example for window.document.
console.log(window.document === document);
console.log(document.nodeType); How It Works
- Step. Same reference as the global document.
- Step. Node type 9 means Document.

window.document is the Document object for this window — the DOM tree you query with querySelector and friends.
Read window.document with no parentheses.
window.document; | Call | What it does |
|---|---|
window.document | The Document for this window. |
Window property in browsers. No import required.
| Parameter | Description |
|---|---|
| window.document | Read-only or assignable depending on the property. No function arguments. |
| Return Value | Description |
|---|---|
| * | The Document for this window. |
Beginner example for window.document.
console.log(window.document === document);
console.log(document.nodeType); Beginner example for window.document.
console.log(document.title.length >= 0);
console.log(typeof document.querySelector); Beginner example for window.document.
console.log(document.documentElement.tagName); window.document is a standard Window property in browsers.
Available in all modern browsers. Not used in plain Node.js without a DOM.
Bottom line: Safe in browsers. Skip in server-only Node scripts.
Continue through the Window properties list.
CODETOFUN NEWS
Get the latest IT news, programming updates, and technology trends directly on your phone.
Your daily dose of tech, straight to your feed.
9 people found this page helpful