Advertisement
Below are the main differences between window and document,
| Window | Document |
| ----------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| It is the root level element in any web page | It is the direct child of the window object. This is also known as Document Object Model (DOM) |
| By default window object is available implicitly in the page | You can access it via window.document or document. |
| It has methods like alert(), confirm() and properties like document, location | It provides methods like getElementById, getElementsByTagName, createElement etc |
Advertisement
JavaScript Coding Exercise 78
Test your knowledge with this interactive coding challenge.
Start CodingAdvertisement