Example 1 — defaultView vs window
On a normal page, the associated window is the global window.
console.log(document.defaultView === window); // true
console.log(document.defaultView.document === document); // true How It Works
- Read
defaultView— MDN: the window for this document. - Compare with
window— same object on the main page. - Round-trip —
defaultView.documentpoints back to this document. - Why it helps: libraries often pass a
Document; this recovers itsWindow.

