Caffeinated Coder
Book an appointment
Lesson 17 · How JavaScript really works

Modules

A module is one JavaScript file with its own scope: nothing leaves it unless it is exported, and other modules get it only by importing it. Follow two real files, counter.js and main.js, as the engine loads them once, links each import to the exporting module's own binding, runs the dependency first, and then shows why an import is live, why a private name stays hidden, and why you cannot assign to an import.

11 min10 steps5 questionsIntermediate
Fig 17 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.