Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

exporting functions js

//// Exporting a single function
module.exports = () => {}

//// Exporting multiple functions
exports.function1 = () => {}
exports.function2 = () => {}// Importing 
const myModule = require('./modulesFolder/myModule');
myFunctions.function1()// Importing with destructuring
const {function1, function2} = require('./modules/myModule');
function1()// Exporting functions lightens the main file 
// but results in slightly longer compiling times
 
PREVIOUS NEXT
Tagged: #exporting #functions #js
ADD COMMENT
Topic
Name
8+7 =