Example 1 — Basic Read
Beginner example for window.self.
console.log(window.self === window);
console.log(typeof window.self); How It Works
- Step. self points at the same object as window.
- Step. typeof is object because Window is an object.

window.self is a reference to the current window. On a normal page, window.self === window is always true.
Read window.self with no parentheses.
window.self; | Call | What it does |
|---|---|
window.self | This window. window.self === window is true. |
Window property in browsers. No import required.
| Parameter | Description |
|---|---|
| window.self | Read-only or assignable depending on the property. No function arguments. |
| Return Value | Description |
|---|---|
| * | This window. window.self === window is true. |
Beginner example for window.self.
console.log(window.self === window);
console.log(typeof window.self); Beginner example for window.self.
const w = window.self;
console.log(w.document === document);
console.log(w.location.href.length > 0); Beginner example for window.self.
function sameWindow(ref) {
return ref === window.self;
}
console.log(sameWindow(window));
console.log(sameWindow({})); window.self is a standard Window property in browsers.
Available in all modern browsers. Not used in plain Node.js without a DOM.
Bottom line: Safe in browsers. Skip in server-only Node scripts.
Continue through the Window properties list.
CODETOFUN NEWS
Get the latest IT news, programming updates, and technology trends directly on your phone.
Your daily dose of tech, straight to your feed.
9 people found this page helpful