We can easily import different functions to a specific file from other .js
files easily, here's how you can do that easily
We'll go through it with a cute example,
- In
math.js
function circumference(radius) {
return 2 * Math.PI * radius
}
function area(radius) {
return Math.PI * radius^2
}
export {circumference, area}
- In
index.js
import {circumference, area } from './math'
// Further code......
Simple and easy! This is how you import and export multiple functions from different files
So, this was a short article that you may have found helpful, comment down more ideas for future articles π
Top comments (0)