Example 1 — Feature-Detect mozBrightness
Check whether the legacy property exists on screen.
if ("mozBrightness" in window.screen) {
console.log("mozBrightness is present (legacy)");
console.log(typeof screen.mozBrightness);
} else {
console.log("mozBrightness not supported");
} How It Works
- Use
in."mozBrightness" in window.screenis the safe detect. - Legacy path. If present, log that it is a legacy property and its type.
- Modern path. Most browsers hit the
elsebranch. - Never assume. Calling without a check is how legacy code breaks.

