i read this stackoverflow question and this one, and other internet searches. the summery of my search is module.exports
and exports
point to same object that will be exported and those exports are accessible with require(<package identifier> or <JS file identifire>).
because the parameter passing strategy in the JS
is call-by-sharing
if we assign a function to module.exports
the exports
object is now useless.(because that exports
still pointing to previous value of module.exports
)
i add this too from nodejs.com
, require()
function will give us exported variables and functions from main module
of a package
or a normal js
file.
now the question is why in express.js file we have other things that are attached to exports while we assigned a function to module.exports
?