window.document
→ Access the DOM.window.location
→ Access and modify the URL.window.history
→ Manage browsing history (back()
/ forward()
/ go(n)
).window.navigator
→ Access browser information (navigator.userAgent
).window.screen
→ Access screen details.window.innerWidth / innerHeight
→ Get the current window size.window.performance
→ Retrieve performance metrics.globalThis
(ES2020)
window
in browsers, global
in Node.js, self
in Web Workers.globalThis
for cross-platform/global variables or functions.globalThis.setTimeout(() => console.log("Hello!"), 1000);
globalThis.myVar = 123; // Accessible anywhere globally
window.alert(message)
→ Display an alert dialog.window.confirm(message)
→ Display a confirmation dialog.window.prompt(message, defaultValue?)
→ Display an input dialog.alert("Hello, world!");
const isConfirmed = confirm("Are you sure?");
const userInput = prompt("Enter your name:");
window.open(url, target)
→ Open a new window/tab (may be blocked by pop-up blockers).
target
can be _self
, _blank
, _parent
, _top
.