Home >Web Front-end >JS Tutorial >What are the differences between export and export default in es6?
Below I will share with you a brief discussion of the functions and differences between export and export default in es6. It has a good reference value and I hope it will be helpful to everyone.
Function:
export and export default have the same functions, that is, they can be used to export (expose) constants, functions, files, and modules etc. so that other files can call it.
Difference:
1. export exports multiple objects, and export default can only export one object
2. export Export objects need to use { }, export default does not require { }, such as:
export {A,B,C};
export default A;
3. When other files refer to objects exported by export default, they do not necessarily use the exported name. Because this method actually sets the export object as the default export object, such as:
Assume that files A and B are in the same directory, implement file B to introduce the export object deObject of file A:
File A: export default deObject
File B: import deObject from './A'
Or:
import newDeObject from '. /A'
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
JavaScript operating principle
Use js custom trim function to delete spaces at both ends
The above is the detailed content of What are the differences between export and export default in es6?. For more information, please follow other related articles on the PHP Chinese website!