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.
Scope in ES Modules vs Scripts in JavaScript
Is strict mode automatic in ES modules?
The answer
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.
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.
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.