How can I use export default to export a function?

Question

How can I use export default to export a function?

Answer

We can use the following syntax to export a function using export default:

export default function myFunctionName(parameters) {
  //function body
}

or

const myVar = function(parameters) {
  // function body
};

export default myVar;
9 Likes

And this?

function myFunctionName(parameters) {
  //function body
}

export default myFunctionName;
2 Likes

@timothytimothytimoth
of course! well done! :face_with_monocle:

2 Likes

Curious would this also work with arrow function?

2 Likes