globalThis is the standard way to access the global object across environments. It is window in browsers, global in Node.js, and self in Web Workers. Use it for portable code that runs anywhere.
The window Object in JavaScript Explained
What is globalThis and why use it instead of window?
The answer
More FAQs in The window Object in JavaScript Explained
It is the global object in browsers. It represents the browser tab and holds global variables (from var), built-in APIs (console, setTimeout, fetch), the DOM (document), and UI methods (alert, prompt).
No. Only var declarations at the top level become properties of window. let, const, and class declarations live in a separate global lexical environment and do not attach to window.
window is the global object representing the browser tab. document is the parsed HTML page inside that tab, accessible as window.document. window holds APIs and globals; document holds the DOM tree.
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.