hasOwnProperty()方法

hasOwnProperty()方法可以检测对象是否有某个属性

var man = {
    legs:2,
    hands:2,
    heads:1
}

man.hasOwnProperty("heads") //true

hasOwnProperty()不能检测原型链上的属性

posted @ 2020-03-21 20:24  liuyanntes'cnblogs  阅读(1495)  评论(0编辑  收藏  举报