Window
The window
object represents the browser window and is supported by the browsers. Global variables, objects, and functions are also part of the window object.
Global variables are properties and functions are methods of the window object.
Let's take an example of the screen properties. It is used to determine the size of the browser window and is measured in pixels.
window.innerHeight
- the inner height of the browser windowwindow.innerWidth
- the inner width of the browser window
Note:
window.document
is same asdocument.location
as the document object model(DOM) is part of window object.
Few examples of the window methods
window.open()
- open a new windowwindow.close()
- close the current windowwindow.moveTo()
- move the current windowwindow.resizeTo()
- resize the current window