Example 1 — Basic Read
Beginner example for window.name.
console.log(typeof window.name);
console.log(window.name === "" || window.name.length >= 0); How It Works
- Step. name is always a string.
- Step. Empty string is common for a normal tab.

window.name is a string name for the browsing context. It starts as "" unless the window or iframe was opened with a name.
Read window.name with no parentheses.
window.name; | Call | What it does |
|---|---|
window.name | The window’s name string. |
Window property in browsers. No import required.
| Parameter | Description |
|---|---|
| window.name | Read-only or assignable depending on the property. No function arguments. |
| Return Value | Description |
|---|---|
| * | The window’s name string. |
Beginner example for window.name.
console.log(typeof window.name);
console.log(window.name === "" || window.name.length >= 0); Beginner example for window.name.
const previous = window.name;
window.name = "demo-tab";
console.log(window.name);
window.name = previous; Beginner example for window.name.
window.name = "alpha";
console.log(window.name.toUpperCase());
window.name = ""; window.name 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