DEV Community

Dhairya Shah
Dhairya Shah

Posted on • Originally published at snowbit-blog.vercel.app

How to export multiple functions

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}
Enter fullscreen mode Exit fullscreen mode
  • In index.js
 import {circumference, area } from './math'

 // Further code......
Enter fullscreen mode Exit fullscreen mode

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)