hasOwnProperty()方法

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

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

man.hasOwnProperty("heads") //true

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

原文地址:https://www.cnblogs.com/yanl55555/p/12541919.html