- Tutorials
- JavaScript Tutorial
- JavaScript Modules
JavaScript Modules
6 lessonsAbout 36 minutesAdvanced
This part of the JavaScript Tutorial runs from JavaScript Modules through to JavaScript Module Patterns. There are 6 lessons here, and working through them takes about 36 minutes at a steady pace.
It follows on from JavaScript Storage & BOM, so finish that first if you have not already — the examples below assume you are comfortable with it.
Each lesson below says what it covers before you open it. Read them in order the first time; afterwards this page works as a index you can jump back into when you need to check one thing.
- 1JavaScript ModulesA module is a file that can export values for other files to import.
- 2JavaScript exportexport makes a function, variable or class available to other modules.
- 3JavaScript importimport brings an exported value from another module into the current file.
- 4JavaScript Module ScriptsA script becomes a module by adding type="module" to its tag.
- 5JavaScript Dynamic Importimport() loads a module while the program is running, returning a promise.
- 6JavaScript Module PatternsBefore real modules existed, JavaScript used closures to fake the same isolation.
