关于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

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值