外观模式,该模式会触发一系列的私有行为,但用户不会接触到,我们让facade编程一个不需要关注实现细节,而且更容易使用的一个特性
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
</body>
<script>
var module = (function(){
var _private ={
i:5,
get:function(){
return this.i;
},
set:function(val){
this.i = val;
},
run:function(){
console.log(this.i);
},
jump:function(){
cosole.log(‘jumping‘);
}
};
return {
facade:function(args){
_private.set(args.val);
_private.get();
if(args.run){
_private.run();
}
}
};
}());
module.facade({run:true,val:10})
</script>
</html>
原文地址:http://www.cnblogs.com/lihaozhou/p/3852361.html