I know that when you do require('./file') where the file.js export is an IIFE, that function will immediately run (obviously). I'm just not sure how to deal with this if the IIFE takes arguments.
I'm new to JS go easy on me please.
For something like this:
//iifeFile.js
module.exports =
(function(arg1, arg2){
//stuff
})();
I feel like I read somewhere that you could run it this way
//index.js
const a = require('./iifeFile')(arg1, arg2);
but that throws TypeError: require(...) is not a function
What is the correct syntax to call this?
Make the
exporta regular function: