Categories
Vue Answers

How to export more than one variable in ES6?

Spread the love

Sometimes, we want to export more than one variable in ES6.

In this article, we’ll look at how to export more than one variable in ES6.

How to export more than one variable in ES6?

To export more than one variable in ES6, we can put all the variables in the curly braces.

For instance, we write

store.js

const testObject = Parse.Object.extend("TestObject");
const post = Parse.Object.extend("Post");

export { testObject, post };

to export the testObject and post in a module.

Then we import the members from store.js with

import { testObject, post } from '../store'

Conclusion

To export more than one variable in ES6, we can put all the variables in the curly braces.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *