ES6 Javascript exports, imports and the difference between 'default export' & 'export'
ES6 provides us with a new way to export and import in our files.
ES5 in Node we have module.exports and require()
We export our object our method using module.exports
And we import it by using require('/path/to/export');
In ES6
We import our code with 'import'
We export our code with "export default". According to the documentation, we we use default, 'there is only a single default export per module. A default export can be a function, a class, an object or anything else'.
We want to export more than one module in a file, we used named exports.
And we can import them by name
On the server it hasn't mattered that much if we imported a big module but on the frontend, we want to be as lightweight as possible. This is especially true since most people are using their phones to surf the web. In these cases we want to use named exports and imports only import what is essential to the frontend application.
Leave ES6 Javascript exports, imports and the difference between 'default export' & 'export' to:
Read more #es6 posts
Best Posts From positivelyzack
We have not curated any of positivelyzack's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From positivelyzack
- Adding props or functionality to React children
- Positive Product Design
- Half Life: The Decay of Utility of Software Knowledge or why you should learn to learn
- Pure Functions
- Deploying a fullstack React app to Heroku
- Components with Props In React
- The structure of app created with the create-react-app tool.
- ES6 Javascript exports, imports and the difference between 'default export' & 'export'