MODULES
MODULES
It is ES6 feature.
Modules are used to break our code into separate files. This helps to
maintain a code base.
Modules are exported from external file.
Exported modules are imported with import statements.
index.html :
Importing a module :
To import a module, we need to use the import keyword.
To import the modules we need to specify the path .
When you import the named export, you must have to use the
same name as the corresponding object inside { }.
When you import the default export, we can give any name.
app.js
example for variables
index.mjs
Example for function
app.js
index.mjs
index.mjs
Example for function.
app.js
index.js
app.js
index.js
app.js
index.mjs