Sometimes, we want to export arrow functions in JavaScript.
In this article, we’ll look at how to export arrow functions in JavaScript.
How to export arrow functions in JavaScript?
To export arrow functions in JavaScript, we can use export
directly with arrow functions.
For instance, we write
const hello = () => console.log("hello");
export default hello;
to export the hello
function as a default export with export default
.
We can also write
export const hello = () => console.log("hello");
to export hello
as a named export.
Conclusion
To export arrow functions in JavaScript, we can use export
directly with arrow functions.