It depends on your purpose. If you only need the current scaling, which you can use:
window.devicePixelRatio
But the value is not equal to the zoom level for all devices, because on HighDPI devices (4k Display, Smartphone, ...), the initial value is not equal to 1, since default scaling is used to compensate for higher pixel resolution.
source share