WINDOW
- Be main JavaScript object root (a.k.a global object in a browser)
- Represent an open window in a browser
- NOTES: If a document contain frames, browser creates 1 window object for HTML document & 1 additional window object for each frame.
WINDOW.DOCUMENT
- The document object is the root node of HTML document
- An HTML document loaded into a web browser becomes a document object
DISTINCTION: WINDOW VS. DOCUMENT
For instance, with .onload():
- window.onload is fired when entire page loads, including its content (images, CSS, scripts, etc.).
- document.onload is called when the DOM is ready (browser has parsed HTML & built the DOM tree) – which can be prior to images and other external content is loaded.
Happy Coding!