Wednesday, February 24, 2016

exports as constructor

app.js


console.log('Hello world');
var x = 1;
var y = 2;
console.log(x * y);
var msg = require("./msgs.js");
//console.log(msg.first);
//console.log(msg.second);
//console.log(msg.msg1);
var o = new msg();
console.log(o.first);


msgs.js as constructor

module.exports =function (){
   this.first= "this is a msg";
}

No comments:

Post a Comment