hashnode-blogs

Let’s explore ES6 modules πŸ˜ƒ

Prerequisites 🦿

What are modules and what are commonjs and es6 modules πŸ€”

When you start doing cool stuffs with javascript in terminal instead of browser.

you write javascript code in file like index.js, that file is known as a module.

Now there are two types of modules

we have already discussed about default module environment provided by nodejs -> commonjs

Lets write some code and discuss es6 modules πŸ§‘β€πŸ’»

Lets activate es6 module environment 🏞️

Come on! lets write some code for real πŸ‘¨β€πŸ’»πŸ‘©β€πŸ’»

the above program was the example of β€œ default export β€œ

In es6 module, there are two types of exports

So lets see named export

An example of module containing both named and default export

Lets discuss the difference between default and named export

the default export

the named export

Examples πŸ§ͺ

you can default export without name

string

functions

classes

you can use names too. If you want