Module.exports.log vs module.exports

Module.exports.log vs module.exports
0

#1

Whats the difference between

module.exports.log

and just…

module.exports


#2

This first one you’re exporting an object with a property log.

module.exports.log = function () {// something } is saying that when you import that you’ll get { log: function () { // something }.

like

var myModule = {};
myModule.myExports = {};
myModule.myExports.log = function(thing) { console.log(thing) };

function myRequire(module) {
  return [module].myExports;
}

Then

> var myLogger = myRequire('myModule');
> myLogger.log('Hello')
Hello

Second one is anything, you haven’t specified - a literal like module.exports = 'Foo' or an object literal, or whatever.