Modules
Both modern JS and TypeScript support modules. Each file is a module, than can export some properties:
Which then are imported in another file:
Each file can also have a default export, which means you don't have to name the exported property:
You can name it when importing:
You can also mix both styles:
Importing npm modules
Importing code installed via npm is done by specifying the package name instead of relative path:
Some (usually older) packages have no default export and have to be imported as a group of properties;
Resources
Last updated