DEV Community

Dhairya Shah
Dhairya Shah

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

2 1

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)

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay