|
Be the first user to complete this post
|
Add to List |
window vs document
Web browser is made up of hierarchy of objects. At the root level we have a window object.
Window
- It is the root level element in any web page.
- All the global variables are defined on the window object.
- For example,
alert(), confirm()are methods defined on thewindowobject. - Writing
alert()is similar towindow.alert() - Also, properties like
document, locationare properties of thewindowobject. - window API
- For example,
Watch the following video to know more about the window object.
[youtube https://www.youtube.com/watch?v=VSgSNQ1-KBo]
Document
- It is the direct child of the
windowobject. It is aka Document Object Model (DOM). - You can access it via
window.documentordocument. documentobject has many useful methods defined on it.- For example,
document.getElementById(),document.getElementByTagName(),document.createElement(),document.querySelector()and many more - document API
- For example,
Watch the following video to know more about the document object.
[youtube https://www.youtube.com/watch?v=XllU4HswEbc]
Also Read:
- position: relative
- Pure vs Impure functions
- querySelector vs getElementById
- css - vertically align text
- Testing promise sequence using mocha, chai, chai-as-promised, sinon