Manipulating documents, references
Basic objects
-
MDN:
document
object: The document (represented by the DOM in browsers) is the actual page loaded into thewindow
, and is represented in JavaScript by theDocument
object. You can use this object to return and manipulate information on the HTML and CSS that comprises the document, for example get a reference to an element in the DOM, change its text content, apply new styles to it, create new elements and add them to the current element as children, or even delete it altogether. -
MDN:
window
object: Thewindow
is the browser tab that a web page is loaded into; this is represented in JavaScript by theWindow
object. Using methods available on this object you can do things like return thewindow
’s size (seeWindow.innerWidth
andWindow.innerHeight
), manipulate the document loaded into thatwindow
, store data specific to that document on the client-side (for example using a local database or other storage mechanism), attach anevent handler
to the currentwindow
, and more. -
MDN:
navigator
object: The navigator represents the state and identity of the browser (i.e. the user-agent) as it exists on the web. In JavaScript, this is represented by theNavigator
object. You can use this object to retrieve things like the user’s preferred language, a media stream from the user’s webcam, etc.
https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Client-side_web_APIs/Manipulating_documents#the_document_object_model