JavaScript: window, document and screen

Ananth Astaputra
1 min readDec 4, 2020

Window

The JavaScript window object sits at the top of the JavaScript Object hierarchy and represents the browser window. The window object is supported by all browsers. All global JavaScript objects, functions, and variables automatically become members of the window object. The window is the first thing that gets loaded into the browser. This window object has the majority of the properties like length, innerWidth, innerHeight, name, if it has been closed, its parents, and more.

alert, open, prompt e.t.c, are some of the methods of the window object. Each browser tab has its own top-level window object. Each of these windows gets its own separate global object.

Document

The Document interface represents any web page loaded in the browser and serves as an entry point into the web page’s content, which is the DOM tree. When an HTML document is loaded into a web browser, it becomes a document object. It is the root node of the HTML document. 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.

Properties:

screen.width
screen.height
screen.availWidth
screen.availHeight
screen.colorDepth

--

--

Ananth Astaputra
0 Followers

Enthusiastic in technological updates