自定义一个hello模块,并对外展现
hello.js文件内容:
function Hello(){
var name;
this.setName = function(thyName){
name = thyName;
};
this.sayHello = function(){
console.log('hello:'+name);
};
};
module.exports =Hello;
主程序调用:
var Hello = require('./hello')
hello = new Hello();
hello.setName('wahahah');
hello.sayHello();