What does this point to at the global level in JavaScript?
In a non-module script, this points to the global object (window in browsers). In ES modules, top-level this is undefined.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in The Shortest JavaScript Program and the Global Object
An empty file. Even with no code, the engine creates a global execution context, a global object (window in browsers, global in Node.js), and a global this binding pointing to the global object.
window in browsers, global in Node.js, self in Web Workers. ES2020 introduced globalThis to unify them, so globalThis always refers to the global object regardless of environment.
Yes, in browsers. Variables declared with var at the top level become properties of the window object. let, const, and class declarations do not become properties of window.
Still have questions?
Browse all our FAQs or reach out to our support team
