Value
A WindowProxy object.
Examples
Uses of window.self like the following could just as well be replaced by window.
js
if (window.parent.frames[0] !== window.self) {
// this window is not the first frame in the list
}
Furthermore, when executing in the active document of a browsing context, window is a reference to the current global object and thus all of the following are equivalent:
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
Specifications
| Specification |
|---|
| HTML # dom-self-dev |
Browser compatibility
See also
- Its
Workerequivalent,WorkerGlobalScope.self.