JS Coding Questions Logo
JS Coding Questions
#77💼 Interview

What is the difference between window and document

Advertisement

728x90

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

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 78

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
77of476