A very basic concept in JavaScript ES6 is Named Exports
. This is a post with examples of two very simple approaches to export several values from a single module. It can be used zero or multiple times per module.
Named Exports
When we name export a variable or function, we can import it in another file and use it without having to rewrite the code.
We can export multiple things, for each thing we want to export.
The first example is given below:
export const addition = (a,b) => {
return a+b;
}
export const multiplication = (a,b) => {
return a*b;
}
Another approach for named export is by creating multiple functions in one single module and placing them all in the export statement. The following is an example of that:
const addition = (a,b) => {
return a+b;
}
const multiplication = (a,b) => {
return a*b;
}
export {addition,multiplication} ;
Top comments (2)
Nice oneπ
Thanks