October 2018
Intermediate to advanced
590 pages
15h 5m
English
Inside a module, you can choose to not export anything. Or, you can export primitive values, functions, classes, and objects. There are two types of exports—named exports and default exports. You can have multiple named exports in the same module but only a single default export in that module.
In the following examples, we will create a user.js module that exports the User class, a tasks.js module that tracks the count of total completed tasks, and a roles.js module that exports role constants.
Let's have a look at user.js file:
1. export default class User {2. constructor (name, role) {3. this.name = name;4. this.role = role;5. }6. };
In this module, we export the User class inline as the default export by placing the keywords ...
Read now
Unlock full access