What are the major differences between Javascript ES6 modules and angular 2 modules?

962    Asked by SanjayDutt in Python , Asked on Jan 13, 2020
Answered by Arun Singh

ES6 modules:

The ES6 Modules, which also goes by the name JS modules or JavaScript modules or ECMAScript modules are part of the JavaScript Language.

The JS Modules are stored in a file. There is exactly one module per file and one file per module.

These modules contain small units of independent, reusable code. They export a value, which can be imported and used in some other module.

Purpose of ES6 Modules:

Avoid leaking code to the global namespace,

Encapsulate code to hide implementation details,

Angular Modules:

Angular Modules are an Angular-specific construct.

Angular Modules logically group different Angular artifacts such as components, pipes, directives, etc.

Angular Modules in the form of the @NgModule decorator provide metadata to the Angular compiler which in turn can better “reason about our application” structure and thus introduce optimizations.

Purpose of Angular Modules:

organize the Angular application parts into cohesive blocks

helps to keep the Separation of concerns



Your Answer

Interviews

Parent Categories