The “screen” property of the “window” object returns the screen object, which contains the information about the user’s screen.
The “screen” object is very simple. It provides a couple of properties to retrieve user’s screen information.
- width, height : the total width or height of the screen
- availWidth, availHeight : available screen width or height (excluding the Windows Taskbar)
- colorDepth : the color resolution (in bits per pixel) of the screen
- pixelDepth : the same as colorDepth
console.log(screen.width + ", " + screen.height); console.log(screen.availWidth + ", " + screen.availHeight); console.log(screen.colorDepth + ", " + screen.pixelDepth);
The “colorDepth” property is identical to the “pixelDepth” property. But “pixelDepth” is supported only on IE10 or later. Meanwhile, “colorDepth” is supported in older IE versions, too.