Modules in JavaScript

KlassenPromises

Modules allow you to split code into separate files for better organization, reusability, and maintainability. ES6 introduced a standard module system with import and export.

In browsers, use type="module" on script tags. Modules are loaded asynchronously and have strict mode by default.

Named Exports

Export multiple values with the export keyword.

Default Export

One main export per module – import with any name.

Mixing Named and Default

Browser Module Loading

Use type="module" and relative/absolute paths. Modules are deferred and cached.

Dynamic Imports

Quick Quiz

Wir haben die Materialien überprüft, dennoch können Fehler vorkommen. Der Inhalt dient ausschließlich Bildungszwecken, daher verwende ihn auf eigene Verantwortung und überprüfe ihn bei Bedarf mit anderen Quellen.

✨ Frag Lara — deine KI-Lernpartnerin

Entsperre personalisierte Lernunterstützung. Lara kann Lektionen erklären, Themen zusammenfassen und deine Lernfragen beantworten — verfügbar ab dem Go-Tarif.


Lara hilft dir, schneller zu lernen — exklusiv für ReadyTools Go-, Plus- und Max-Mitglieder.

Verfolge deinen Fortschritt 🚀

Lerne einfacher, indem du deinen Fortschritt kostenlos verfolgst.