Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I import many variables at once in javascript in NodeJS?

Let's say I have a javascript module first_file.js:

var first = "first",
    second = "second",
    third = "third";

module.exports = {first, second, third};

How do I import these into another file in one line? The following only imports third:

var first, second, third = require('./path/to/first_file.js');
like image 939
YPCrumble Avatar asked Jan 08 '16 18:01

YPCrumble


1 Answers

You could store them in an array:

module.exports = [first, second, third];
like image 127
gnerkus Avatar answered Oct 24 '22 21:10

gnerkus