I have a codebase of javascript that I am working on, and have encountered a piece of structure that I am not familiar with. I would just like the name of it so I know what to look up and read about. Any additional information is appreciated.
This is in a Node.js/express environment.
What I'm specifically asking about is the fizz thing in file2.js, referenced in the line marked with a /*!!*/ in file1.js. It looks like some sort of wrapper around a series of functions. What is its proper name?
//file1.js
const file2 = require('filepath/file2')
foo.get('/bar', (req, res) => {
file2.fizz.buzz(req.field.item, res) /*!!*/
localfunction(param1, param2)
})
//file2.js
module.exports = {
fizz: {
buzz: (str, res) => {
console.log("buzz")
},
bang: (param1, param2) => {
console.log("bang!")
}
}
}
Thanks!
/*! */sign here is a good answer for it stackoverflow.com/a/11248430/9453736fizzitself? An object property (fizzbeing the property name, the object being the property value)? You might want to take a quick step back and spin through a JS tutorial real quick.module.exports = {}-> module.exports is an object;fizz: {}-> the propertyfizzonmodule.exportsis also an object;` buzz: (str, res) => {...}` -> the propertybuzzonmodule.exports.fizzis a function.x = require('file2.js'); x.fizz.buzz()is how you access that function.fizzobject?