Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

What does default export mean in ecmascript 6?


Asked by Miguel Whitney on Dec 02, 2021 FAQ



An ECMAScript 6 module can pick a default export, the most important exported value. Default exports are especially easy to import. The following ECMAScript 6 module “is” a single function: An ECMAScript 6 module whose default export is a class looks as follows:
Additionally,
The module syntax suggesting that the default export “is” the module may seem a bit strange, but it makes sense if you consider that one major design goal was to make default exports as convenient as possible. Quoting David Herman: ECMAScript 6 favors the single/default export style, and gives the sweetest syntax to importing the default.
Besides, ECMAScript 6 modules 16.3. The basics of ES6 modules 16.3.1. Named exports (several per module) 16.3.2. Default exports (one per module) 16.3.3. Imports and exports must be at the top level 16.3.4. Imports are hoisted
In fact,
Concerning the default export, there is only a single default export per module. A default export can be a function, a class, an object or anything else. This value is to be considered as the “main” exported value since it will be the simplest to import.
Keeping this in consideration,
A default export can be a function, a class, an object or anything else. This value is to be considered as the “main” exported value since it will be the simplest to import.