Example 1 — Feature-Detect
Check whether globalPrivacyControl exists before reading it.
const supported = "globalPrivacyControl" in navigator;
console.log(supported ? "GPC available" : "GPC missing"); How It Works
- Use
in. Tests for the property without reading a value. - Expect limited support. Firefox often has it; Chrome/Safari may not.
- Log clearly. Students see support without throwing.
- Keep a fallback. Missing GPC → normal consent flow.

