Example 1 — Feature-Detect Support
Check whether the property exists before reading it.
if ("activeVRDisplays" in navigator) {
console.log("available (legacy WebVR)");
} else {
console.log("missing — prefer navigator.xr");
} How It Works
- Use
in. Checks whether the property exists onnavigator. - Legacy path. If present, you are in an old WebVR-capable environment.
- Common path. Most browsers today omit it entirely.
- Next step. Point learners toward
navigator.xrfor new work.

