Home
Recent Q&A
Java
Cloud
JavaScript
Python
SQL
PHP
HTML
C++
Data Science
DBMS
Devops
Hadoop
Machine Learning
Azure
Blockchain
Devops
Ask a Question
What is the difference between window and document in Javascript?
Home
JavaScript
What is the difference between window and document in Javascript?
asked
Oct 1, 2023
in
JavaScript
by
GeorgeBell
What is the difference between window and document in Javascript?
javascript-interview-questions-answers
Please
log in
or
register
to answer this question.
1
Answer
0
votes
answered
Oct 1, 2023
by
GeorgeBell
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
...