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;
10 Likes