关于hasOwnProperty()方法的应用

 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 var man = {
10     a:1,
11     b:2,
12     c:3
13 }
14 Object.prototype.clone = function(){
15     alert(11)
16 };
17 // for (var i in man) {
18 //     console.log(man[i])
19 // };  //循环出所有属性包括继承来的
20 for(var i in man){
21     if (man.hasOwnProperty(i)) {
22         console.log(man[i])
23     };
24 }  //循环出本实例的所有属性,不包括继承出来的
25    </script> 
26 </body>
27 </html>
坚持下去就能成功
原文地址:https://www.cnblogs.com/suoking/p/4870072.html