Example 1 — Read availWidth
Log the available screen width in CSS pixels.
console.log(window.screen.availWidth);
console.log(typeof screen.availWidth); How It Works
- Access
window.screen. Every window exposes aScreenobject. - Read
availWidth. MDN: horizontal space available to the window (CSS px). - Check
typeof. It is always a number in browsers that support Screen. - Do not write to it. The property is read-only.

