info@enlightsolution.com           01710-318199           9:00AM - 6:00PM

  • Home
  • Services
    • Custom Software Development
    • Web Application
    • Mobile Application
  • Products
    • Enlight Business Solutions
    • Enlight Accounting
    • Enlight HR & Payroll
    • Enlight POS
    • Asset Management System
  • Portfolio
  • Insights
  • About Us
  • Career
  • Contact US

ECMAScript Modules

ECMAScript Modules

by Admin / Thursday, 30 May 2019 / Published in JavaScript

ECMAScript Modules:

JavaScript standard from 2015 introduces its own, different module system. It is usually called ES modules, where ES stands for ECMAScript. ECMAScript modules are the official standard format to package JavaScript code for reuse. Modules are defined using a variety of import and export statements.

ES Modules Syntax: The syntax to export and import. An HTML page can add a module by using a <script> tag with the special type=”module” or nomodule attribute:

Export:

The export statement is used when creating JavaScript modules to export functions, objects, class or primitive values from the module so they can be used by other programs with the import statement. Many way use export. Example:

Exporting individual features: Every functions, objects, class before use export.

Example: 

Export Default : There are two different types of export, named and default. We can have multiple named exports per module but only one default export per file. Each type corresponds to one of the above syntax:

Example:

Export list: we can put export separately. Here we first declare, and then export.

Example:

Renaming Exports: We can also use as to export under different names(change name).

Example:

Import:

Import – The static import statement is used to import bindings  which are exported by another module. Imported modules are in strict mode whether we declare them as such or not. Many way use import. Example:

Importing Named: We can have multiple named exports per module. Named exports are useful to export several values. During the import, it is mandatory to use the same name of the corresponding object.

Example:

 

Importing Default: We can have only one default export per module. A default export can be imported with any name.

Example:

 

Importing Default and Named: We can have only one default export per module. A default export can be imported with any name.

Example:

 

Importing All: Import all of a module’s exports as a module object.

Example:

About Admin

What you can read next

Namespaces in Typescript
Expressions and Statements in JavaScript (Part 1)
How to save image and load a picture in A pixel art editor

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

ENLIGHT SOLUTIONS

Enlight Solutions is working with Leading software development system. We provide out clients nice and fluent software solutions in minimum amount of time.

Quick Links

  • About Us
  • Products
  • Services
  • Portfolio
  • Blog
  • Career

All right reserved.
ENLIGHT SOLUTIONS @ 2019

  • Home
  • contact us
TOP