Answers for "exporting functions js"

1

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
Posted by: Guest on December-22-2021
0

exporting functions

//myfile.js
export function fn1() {...} 
export function fn2() {...} 
import * as MyFn from blabla
                       myFn.fn1();
Posted by: Guest on April-30-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language