How to determine that the browser window has lost focus?

The tab remains the same, the browser window does not turn off. Just open the calculator app or just switch to any other app in the system, for example a text editor or another browser.

document.visibilityState in this case will be visible
March 20th 20 at 11:42
2 answers
March 20th 20 at 11:44
window.addEventListener("blur", () => {console.log(111)})
March 20th 20 at 11:46
window.onblur = () => console.log('noo')
also here is the link:

Find more questions by tags JavaScriptBrowsers