Detecting the browser's zoom level from JavaScript is, in practice, not something you can do reliably today. There's no evidence that browsers deliberately withhold this information; the limitation comes from the tools available, none of which return a usable value across engines.

The candidate APIs and why they fall short

Visual Viewport

window.visualViewport is defined in Firefox, Safari, and desktop Chrome, and the spec is a draft. But window.visualViewport.scale is always 1 in Safari and Chrome and undefined in Firefox. The spec frames scale around pinch-zoom specifically, so it may simply not be intended to report desktop browser zoom.

Pixel density

window.devicePixelRatio shifts with zoom in Chrome and Firefox: it rises as you zoom in and falls as you zoom out. You could record a baseline value and infer zoom from changes to it, but Safari leaves the value untouched regardless of zoom. Operating-system zoom also affects the reading, and a page can load at an already-zoomed level, which corrupts the baseline from the start.

Older workarounds

A 2013 script that tries to derive zoom works in Chrome, fails entirely in Safari, and reports incorrectly in Firefox. Even a working version would depend on user agent detection, which is on its way out, and on convoluted hacks.

The use case that motivates it

One developer wanted to lay out cemetery plots as a CSS grid — a top-down blueprint of a graveyard with a lot of information in the layout. Zoomed out to see the whole site, text sized to fit inside each grave or box becomes unreadable. The ideal behaviour is to hide that text while zoomed out (say, via a .hide-text class) and restore it once the user zooms in far enough.

// Dunno if "resize" is best. I don't know what the "change zoom" event would be
window.visualViewport.addEventListener("resize", viewportHandler);
function viewportHandler(event) {
  // NOTE: This doesn't actually work at time of writing
  if (event.target.scale > 3) {
    document.body.classList.remove("hide-text");  
  } else {
    document.body.classList.add("hide-text");
  }
}

Conclusion

Cross-browser behaviour here is messy enough that zoom detection isn't currently viable. Corrections are welcome, but the practical answer is: you can't really do this right now.