JavaScript Window self Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

window.self is a reference to the current window. On a normal page, window.self === window is always true.

Syntax

Read window.self with no parentheses.

JavaScript
window.self;
CallWhat it does
window.selfThis window. window.self === window is true.

Window property in browsers. No import required.

Parameters

ParameterDescription
window.selfRead-only or assignable depending on the property. No function arguments.

Return Value

Return ValueDescription
*This window. window.self === window is true.

JavaScript Examples

Example 1 — Basic Read

Beginner example for window.self.

JavaScript
console.log(window.self === window);
console.log(typeof window.self);
Try It Yourself

How It Works

  1. Step. self points at the same object as window.
  2. Step. typeof is object because Window is an object.

Example 2 — Practical Use

Beginner example for window.self.

JavaScript
const w = window.self;
console.log(w.document === document);
console.log(w.location.href.length > 0);
Try It Yourself

How It Works

  1. Step. You can store self in a variable.
  2. Step. It still has document and location.

Example 3 — Check / Compare

Beginner example for window.self.

JavaScript
function sameWindow(ref) {
  return ref === window.self;
}
console.log(sameWindow(window));
console.log(sameWindow({}));
Try It Yourself

How It Works

  1. Step. Compare with === to test identity.
  2. Step. A plain object is not the window.

Browser & Runtime Support

window.self is a standard Window property in browsers.

✓ Browser Window API

window.self

Available in all modern browsers. Not used in plain Node.js without a DOM.

Browsers Environment
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
window.self Excellent

Bottom line: Safe in browsers. Skip in server-only Node scripts.

Frequently Asked Questions

It is a property that returns the window itself. window.self === window is true.
When you want to stress “this window” or mirror WorkerGlobalScope.self. Everyday code can use window.
In a browser window, both refer to the same global object. globalThis also works in workers and Node.
Open the Window Properties index for every property in this series.

Browse more properties

Continue through the Window properties list.

Next →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful