给Object扩展新方法

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>关于hasOwnProperty()方法的应用</title>
 6 </head>
 7 <body>
 8    <script>
 9 if (typeof Object.prototype.clone === "undefined") {
10    Object.prototype.clone = function () {
11     alert(this.b)
12    };
13 }
14 var a ={b:1}
15 a.clone()
16    </script> 
17 </body>
18 </html>

 

posted @ 2015-10-11 21:43  挥刀  阅读(214)  评论(0编辑  收藏  举报