MDN self-hosted library · e01.org

Window: self property

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

js
if (window.parent.frames[0] !== window.self) {
  // this window is not the first frame in the list
}
js
const w1 = window;
const w2 = self;
const w3 = window.window;
const w4 = window.self;
// w1, w2, w3, w4 all strictly equal, but only w2 will function in workers