how to exports many function to another module - node js code example
Example 1: node module export multiple functions
const animalName = (name) => {
console.log(name)
}
const animalSound = (sound) => {
console.log(sound)
}
module.exports = {animalName, animalSound}
const animalLib = require('./location_of_file.js')
animalLib.animalName("zebra")
Example 2: node js module export class
module.exports = class Person {
constructor(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
display() {
console.log(this.firstName + " " + this.lastName);
}
}