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

