Implementing modules – the new way
ES6 introduced a new module system called ES6 modules. The ES6 modules are supported natively and therefore, they can be referred as the standard JavaScript modules.
You should consider using ES6 modules instead of the old ways, because they have neater syntax, better performance, and many new APIs that are likely to be packed as the ES6 modules.
Let's have a look at the ES6 modules in detail.
Creating the ES6 modules
Every ES6 module needs to be represented by a separate .js
file. An ES6 module can contain any JavaScript code, and it can export any number of variables.
A module can export a variable, function, class, or any other entity.
We need to use the export
statement in a module to export variables. The export ...
Get React: Building Modern Web Applications now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.