Example 1 — Basic Read
Beginner example for window.closed.
console.log(typeof window.closed);
console.log(window.closed); How It Works
- Step. On the page you are reading, closed is false.
- Step. typeof is boolean.

window.closed is a boolean. It is false while the window can be used, and true after that window has been closed.
Read window.closed with no parentheses.
window.closed; | Call | What it does |
|---|---|
window.closed | true after the window has been closed. |
Window property in browsers. No import required.
| Parameter | Description |
|---|---|
| window.closed | Read-only or assignable depending on the property. No function arguments. |
| Return Value | Description |
|---|---|
| * | true after the window has been closed. |
Beginner example for window.closed.
console.log(typeof window.closed);
console.log(window.closed); Beginner example for window.closed.
function canUse(win) {
return win && !win.closed;
}
console.log(canUse(window)); Beginner example for window.closed.
console.log("closed" in window);
console.log(window.closed === false); window.closed 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