hasOwnProperty()方法

Posted yanl55555

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hasOwnProperty()方法相关的知识,希望对你有一定的参考价值。

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

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

man.hasOwnProperty("heads") //true

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

以上是关于hasOwnProperty()方法的主要内容,如果未能解决你的问题,请参考以下文章