Complete the code to export the function as the default export.
function greet() {
console.log('Hello!');
}
export [1] greet;The keyword default is used to export a single value or function as the default export from a module.
Complete the code to import the default export from the module.
import [1] from './greet.js'; [1]();
When importing a default export, you use a simple name without curly braces.
Fix the error in the export statement to correctly export the default value.
const message = 'Hi there!'; export [1] = message;
The correct syntax for default export of a value is export default value; without an equals sign.
Fill both blanks to export a default arrow function and import it correctly.
export [1] () => { console.log('Welcome!'); }; import greet from './welcome.js'; greet();
To export a default function expression, use export default function. The import uses the default import syntax.
Fill all three blanks to export a default class and import it with a new name.
export [1] class [2] { constructor() { console.log('Created'); } } import [3] from './MyClass.js'; const obj = new [3]();
Use export default class MyClass to export the class. When importing, you can rename the default import to any name you want.