JAVASCRIPT-WINDOW,DOCUMENT AND SCREEN.

Window:

Window object supported by all browsers, most of the global objects, functions and variables are part of window object .Window object is the one that loads first in the browser. In other way its a parent or root of all other objects. window is a property of the Global object when you run JavaScript in a web browser.

DOCUMENT:

Document represents webpage loaded on the browser,when HTML is loaded on browser it becomes the document object.

The document actually gets loaded inside the window object and has properties available to it like title, URL, cookie, etc.

Screen:

Screen is a small information object about physical screen dimensions . It can be used to display screen width, height, colorDepth, pixelDepth etc. It is not mandatory to write window prefix with screen object. It can be written without window prefix.

we can use window.document or window.screen as window is the parent object.

CONCLUSION:

  • window is the execution context and global object for that context's JavaScript
  • document contains the DOM, initialized by parsing HTML
  • screen describes the physical display's full screen.

--

--