There are two types of exports. One is Named Exports and other is Default Exports.
Named Exports: Named exports are useful to export several values. During the import, it is mandatory to use the same name of the corresponding object.
Default Exports: Default exports are useful to export only a single object, function, variable. During the import, we can use any name to import.
Another example of Default Exports with function
Using Named and Default Exports at the same time: It is possible to use Named and Default exports in the same file. It means both will be imported in the same file.
While importing this module.js we can use any name for fun because it is a default export and curly braces for other named exports.
This is a default export. 2
- Difference between node.js require and ES6 import and export
- export command in Linux with Examples
- PHP | ReflectionMethod export() Function
- Export JSON to CSV file in Angular
- PHP | ReflectionClass export() Function
- PHP | ReflectionExtension export() Function
- PHP | ReflectionFunction export() Function
- Node.js | Export Module
- ES6 | Import and Export
- Import and Export in Node.js
- C# | Default Constructor
- CSS | :default Selector
- HTML | DOM Track default property
- How to set the default value for an HTML <select> element?
- HTML | default Attribute
- HTML | <track> default Attribute
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.