JavaScript275 Documents

Anonymous Default Export

In JavaScript files, use an anonymous default export when the exported value is not reused within the module.

Correct

export default {
    title: 'Education',
}

Incorrect

const policy = {
    title: 'Education',
}
export default policy

Exceptions

  • Use a named declaration when the value is reused within the module or when a framework requires a name.

Fix

Export the value directly as the default instead of assigning it to a single-use local binding.