
Understanding ES6 Export and Import
This article was originally published on bmf-tech.com . I realized that I didn't fully grasp the export and import in ES6, so I did some research. How to Use Export The export statement is used to export functions, objects, or primitives from a specified file (or module). Source: MDN - Export Here, export is close to the meaning of defining something. There are two types of exports. Named Exports export { hogeFunction }; // Exporting a declared function export const hoge = 1 ; // Exporting a constant; let and var are also allowed. You can also export using from. export * from ' Hoge ' ; // Wildcard export { hoge , moge , huge } from ' hogemogehuge ' ; // Multiple exports export { importHoge as hoge , importMoge as moge } from ' hogemoge ' ; // Alias Default Exports export default function () {} export default class () {} default means that " if nothing is specified during import, that class or function will be called ." If you want to call a class or function other than default during
Continue reading on Dev.to JavaScript
Opens in a new tab


