Learn JavaScript

Lesson 4 of 9 · Modules: import, export and How Files Find Each Other

Module 11 · Modules: import, export and How Files Find Each Other

When to Use Which: Default or Named, a Module or a Class, ES Modules or CommonJS

Free with an accountReading

Maria's team opens a new project and argues for an hour. One developer wants a default export in every file. Another wants named exports only. A third asks why the cart is a module and not a class. Nobody is wrong about everything, so the argument never ends.

Checking what this lesson needs for you…

What is inside When to Use Which: Default or Named, a Module or a Class, ES Modules or CommonJS

  1. Named exports by default
  2. When a default export earns its place
  3. The style guides that disagree
  4. A module, a class, or a closure
  5. ES modules or CommonJS for new code
  6. Mixing the two, safely
  7. When not to split a file
  8. The whole decision in one table