05.module.js
var hello = require("./helloModule");
/*
exports 和 module.exports
- 通过exports只能使用.的方式来向外暴露内部变量
exports.xxx = xxx
- 而module.exports既可以通过.的形式,也可以直接赋值
module.exports.xxx = xxxx
module.exports = {}
*/
console.log(hello.name);
console.log(hello.age);
hello.sayName();
helloModule.js
/*
module.exports.name = "孙悟空";
module.exports.age = 18;
module.exports.sayName = function () {
console.log("我是孙悟空~~~");
};*/
//exports = module.exports
/*exports = {
name:"猪八戒",
age:28,
sayName:function () {
console.log("我是猪八戒");
}
};*/
/*var a = 10;
var b = a;
a++;*/
// console.log("a = "+a);
// console.log("b = "+b);
/*var obj = new Object();
obj.name = "孙悟空";
var obj2 = obj;
obj2.name = "猪八戒";
obj2 = null;
console.log("obj = "+obj.name);
console.log("obj2 = "+obj2);*/