What is the difference between window and document?

Posted by Jessica Taylor | Updated on

Below are the main differences between window and document,

WindowDocument
It is the root level element in any web pageIt 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 pageYou can access it via window.document or document.
It has methods like alert(), confirm() and properties like document, locationIt provides methods like getElementById, getElementByTagName, createElement etc

If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers