What is top-level this in an ES module?
undefined. In classic scripts, top-level this is the global object (window). In ES modules, it is undefined to prevent accidental global mutation. Use globalThis if you need the global object.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Scope in ES Modules vs Scripts in JavaScript
In classic scripts, top-level var becomes a property of window and this is the global object. In ES modules, top-level variables are module-scoped (not global), this is undefined, and strict mode is automatic.
No. In ES modules, top-level var, let, const, and class are module-scoped. They are not properties of window and are only accessible outside the module if explicitly exported.
Yes. Any file with import or export is automatically in strict mode. You do not need 'use strict'. This catches more bugs like accidental globals and duplicate parameter names.
Still have questions?
Browse all our FAQs or reach out to our support team
