简单的对象分装-快速理解-字面量

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body></body>
<script>
(function(){
var boss = "the boss";//全局变量
var config = {
onlad:function(obj){
name = obj.name || "jack";
console.log(name);
console.log(boss);
config.test();
},
test: function(){
console.log("test");
}
};
//公布函数
window.zz={test:config.onlad}
})();
//调用封装
zz.test({
name:"zhangsan"
});
</script>
</html>
原文地址:https://www.cnblogs.com/zhaozhou/p/7903954.html