Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Share On Stumbleupon
Contact us
Hide Buttons

window vs document

Web browser is made up of hier­ar­chy of objects. At the root level we have a win­dow object.


  • It is the root level ele­ment in any web page.
  • All the global vari­ables are defined on the win­dow object.
    • For exam­ple, alert(), confirm() are meth­ods defined on the window object.
    • Writ­ing alert() is sim­i­lar to window.alert()
    • Also, prop­er­ties like document, location are prop­er­ties of the window object.
    • win­dow API
Watch the fol­low­ing video to know more about the win­dow object.


  • It is the direct child of the window object. It is aka Doc­u­ment Object Model (DOM).
  • You can access it via window.document or document.
  • document object has many use­ful meth­ods defined on it.
    • For exam­ple, document.getElementById(), document.getElementByTagName(), document.createElement(), document.querySelector() and many more
    • doc­u­ment API
Watch the fol­low­ing video to know more about the doc­u­ment object.

You may also like...