Named vs Default Exports in JavaScript

Опубликовано: 26 Октябрь 2024
на канале: Brett Westwood - Software Engineer
2,243
75

Coding with JavaScript or TypeScript is awesome! Here is how to use es6 modules.

Here is a little cheat sheet when dealing with named and default exports in your code.

Named exports must be imported with curly braces and must use the same function name that was exported. Also, you can export multiple functions from a single file using named exports.

Default exports only allow you to export one function per file and you can import these functions without curly braces and can change the function name on the import statement.

#JavaScript #TypeScript #Reactjs #Nextjs #es6