How to pass more than one function in a .js file to another file



I am trying to pass another function in a .js file to html. I used “module.exports” but it will only pass one function. Should I set all functions in one main function or something similar. If so please provide details. If there is an easier way please provide the detail to that.


module.exports = {
fn1: _fn1,
fn2: _fn2

or with es6:

module.exports = { fn1, fn2 };


Sorry for the late response

How would I set this up? I am still very new to electron. I tried it by module .exports examples provided. I know i am doing this the wrong way but I’ll learn it by example provided. I have to call the functions in the index.html file. how do I go about setting it up. I did the “var name = require(’ ');”. The problem is it only calls one and not both. I should mention each function opens its own file to be read in and stored in an array.

here is my set up I am stuck on how to structure things and call them in the html file.



 module.exports = functionList


This isn’t really an electron problem, just so ya know. Maybe look into revealing module pattern or prototype pattern for javascript. You should really get familiar with those, this stuff isn’t electron specific.

   var blah = (function() {
     function _first () {
     function _second () {

     return {
       first: _first,
       second: _second

   module.exports = blah

// in other file
var blah = require('./path/to/blah);
blah.first(); // prints 'first!'


I know it is not per say…but I was stuck. Thanks for the input