pratiks
10/9/2017 - 6:05 PM

Return a Function from require('module.js')

In some cases, you want to return a function when you export a module.

//In some cases, you want to return a function when you export a module. 

//hello.js

module.exports = exports = function(){
  console.log('hey you!')
}

//app.js
var sayhello = require('hello');
sayhello(); // require returned a function instead of an object that holds functions.