Finding property in Object

This question already has an answer here:

  • How do I check if an object has a property in JavaScript? 22 answers

  • Try hasOwnProperty

    if(myObject.hasOwnProperty("1030")) {
        // Do code
    }
    

    It's a bit safer than checking if(myObject["1030"]) . This will return false, if the value is falsey ( false , undefined , null ), which may be desirable, but also does not strictly mean it does not exist.

    链接地址: http://www.djcxy.com/p/27324.html

    上一篇: 如何确定两个JavaScript对象的相等性?

    下一篇: 在Object中查找属性