Home > Web Front-end > JS Tutorial > body text

What are the differences between export and export default in es6?

亚连
Release: 2018-06-07 14:17:46
Original
2733 people have browsed it

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

express sets up query server

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template