Reputation: 11
app.js
var a = function(){
var b = function(){
console.log("hello")
}
}
module.exports = {a}
index.js
console.log(require("./app.js").a().b())
I wantr to get the output "hello" but i am getting error can call property b of undefined
Please help to obtain the result
Upvotes: 1
Views: 31
Reputation: 10071
try this
var a = function () {
var b = function () {
console.log("hello")
}
return {b:b};
}
Upvotes: 3