Recall & Review
beginner
What is a default export in JavaScript modules?
A default export is a way to export a single value or entity from a module so that it can be imported without using curly braces. It represents the main exported value of the module.
Click to reveal answer
beginner
How do you write a default export for a function named
greet?You write: <pre>export default function greet() {<br> console.log('Hello!');<br>}</pre> This exports the <code>greet</code> function as the default export.Click to reveal answer
beginner
How do you import a default export from a module named <code>math.js</code>?You write: <pre>import anyName from './math.js';</pre> You can choose any name for the imported value because it is the default export.Click to reveal answer
beginner
Can a module have more than one default export?
No, a module can only have one default export. Trying to export more than one default will cause an error.
Click to reveal answer
intermediate
What is the difference between default export and named export?
Default export exports a single main value without curly braces when importing. Named exports export multiple values and require curly braces when importing.
Click to reveal answer
How do you import a default export from a module?
✗ Incorrect
Default exports are imported without curly braces using: import value from 'module';
Which of the following is a correct way to export a default value?
✗ Incorrect
You export a default value simply by writing: export default 42;
Can a module have multiple default exports?
✗ Incorrect
A module can only have one default export.
What happens if you import a default export with a different name?
✗ Incorrect
Default exports can be imported with any name you choose.
Which syntax imports both default and named exports from a module?
✗ Incorrect
You import default and named exports together like this: import defaultExport, { namedExport } from 'module';
Explain what a default export is and how it differs from named exports.
Think about how you import the main thing from a module.
You got /4 concepts.
Describe how to export and import a default function from a JavaScript module.
Focus on the function keyword and import naming.
You got /3 concepts.