Aryan PrajapatKnowledge Contributor
What is the difference between window and document
What is the difference between window and document
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Questions | Answers | Discussions | Knowledge sharing | Communities & more.
Below are the main differences between window and document,
Window
It is the root level element in any web page
By default window object is available implicitly in the page
It has methods like alert(), confirm() and properties like document, location
Document
It is the direct child of the window object. This is also known as Document Object Model(DOM)
You can access it via window.document or document.
It provides methods like getElementById, getElementsByTagName, createElement etc