You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -1023,7 +1025,7 @@ I highly recommend to take a look at MDN resources on import/export (see externa
1023
1025
1024
1026
#### Explanation with sample code
1025
1027
1026
-
- Named exports
1028
+
#####Named exports
1027
1029
1028
1030
Named exports are used to export several values from a module. You can only name-export variables (not functions or class), so if you want to name-export a function, you have to store it in a variable before.
While named imports looks like *destructuring*, they have a different syntax and are not the same. They don't support default values nor *deep* destructuring.
1054
+
1055
+
Besides, you can do aliases but the syntax is different from the one used in destructuring:
1056
+
1057
+
```js
1058
+
import { fooasbar } from'myFile.js'; // foo is imported and injected into a new bar variable
1059
+
```
1060
+
1061
+
##### Default import / export
1052
1062
1053
1063
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 considered the "main" exported value since it will be the simplest to import. [Ref: MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export#Description)
1054
1064
@@ -1082,9 +1092,12 @@ console.log(result) // 3
1082
1092
1083
1093
#### External resources
1084
1094
1095
+
-[ES6 Modules in bulletpoints](https://ponyfoo.com/articles/es6#modules)
-[Destructuring special case - import statements](https://ponyfoo.com/articles/es6-destructuring-in-depth#special-case-import-statements)
1100
+
-[Misunderstanding ES6 Modules - Kent C. Dodds](https://medium.com/@kentcdodds/misunderstanding-es6-modules-upgrading-babel-tears-and-a-solution-ad2d5ab93ce0)
1088
1101
-[Modules in JavaScript](http://exploringjs.com/es6/ch_modules.html#sec_modules-in-javascript)
0 commit comments