javascript 设计模式之代理模式
//代理模式需要 3 个方法 //1.买家 function maijia(argument) { this.name = "小明" } //2.中介 function zhongjie() { } zhongjie.prototype.maifang = function(){ new fangdong (new maijia()).maifang("20 万"); }; //3.房东 function fangdong(maijia) { this.maijia_name = maijia.name; this.maifang = function (money) { alert("收到了来自["+this.maijia_name+"]"+money+"人民币"); } } (new zhongjie).maifang();