O'Reilly logo
  • Radoslav Asenov thinks this is interesting:

Comprehending Angular modules


Cover of Angular 6 by Example


In JavaScript, modules are individual files with JavaScript code in them. To make what’s in them available, you write an export statement, usually after the relevant code, like this:

export class AppComponent { ... } Then, when you need that file’s code in another file, you import it like this:

import { AppComponent } from './app.component'; JavaScript modules help you namespace, preventing accidental global variables.