首页 > 代码库 > JS之代理模式

JS之代理模式

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>Document</title>
 6 </head>
 7 <body>
 8     <script>
 9     //1,买家
10         function maijia (argument) {
11             // body...
12             this.name = 小明
13         }
14 
15 //2.中介
16         function zhongjie(){
17             zhongjie.prototype.maifang = function(){
18                 new fangdong(new maijia()).maifang(20W);                    
19             }
20         }
21 //
22         function fangdong(maijia){
23             this.maijia_name = maijia.name;
24             this.maifang = function  (monney) {
25                 // body...
26                 alert(拿到了+this.maijia_name+monney)
27             }
28         }
29         (new zhongjie).maifang();
30         //===  var a  = new zhongjie();a.maifang();
31         
32         
33     </script>
34     www.alloyteam.github.io
35 </body>
36 </html>

 

JS之代理模式