Example 1 — Basic Read
Beginner example for window.screen.
console.log(window.screen === screen);
console.log(typeof screen.width); How It Works
- Step. Global screen matches window.screen.
- Step. width/height are numbers.

window.screen describes the display. screen.width and screen.height are the screen size in pixels.
Read window.screen with no parentheses.
window.screen; | Call | What it does |
|---|---|
window.screen | The Screen object for the display. |
Window property in browsers. No import required.
| Parameter | Description |
|---|---|
| window.screen | Read-only or assignable depending on the property. No function arguments. |
| Return Value | Description |
|---|---|
| * | The Screen object for the display. |
Beginner example for window.screen.
console.log(window.screen === screen);
console.log(typeof screen.width); Beginner example for window.screen.
console.log(screen.width >= window.innerWidth); Beginner example for window.screen.
console.log(screen.width + "x" + screen.height); window.screen is a standard Window property in browsers.
Available in all modern browsers. Not used in plain Node.js without a DOM.
Bottom line: Safe in browsers. Skip in server-only Node scripts.
Continue through the Window properties list.
CODETOFUN NEWS
Get the latest IT news, programming updates, and technology trends directly on your phone.
Your daily dose of tech, straight to your feed.
9 people found this page helpful