Browser - Document variable (DOM) - Javascript
Table of Contents
1 - About
The document variable exists as a global variable and is provided by the browser (Not by the Javascript engine)
It represents the DOM document. Ie an interface to HTML document manipulation.
The DOM is a special object, often called a host object
The document variable is:
- is a property of the window object
- accessible globally through an alias
2 - Articles Related
3 - Example
4 - Browser Detection
The presence of the document object tells you that Javascript is running in a browser.
if (typeof document !== 'undefined') {
// We are in a browser context
} else {
// We are in a non-browser context (node,..)
}