壹.2.14 模块化开发
一线互联网公司几乎都在推行模块化开发
壹.2.14.1 老一辈前端工程师如何实现模块化
let module = (function() {
var _version = "1.0";
var _name = "a-nice-module";
function _log(x) {
console.log(x);
}
function say(s) {
_log(s);
}
return {
name: _name,
say: say
};
})();
console.log(module._version);//>> undefined
console.log(module._log);//>> undefined
console.log(module.name); //>> a-nice-module
module.say("hello"); //>> hello壹.2.14.2 AMD 和 CommonJS
壹.2.14.3 ECMAScript 6 的模块化
1.模块里的变量是以引用形式传递的
2.模块嵌套
最后更新于
这有帮助吗?