1, in运算符
2, hasOwnProperty()
3, != undefined
//检测o对象里是否有属性a
var o={a:1,b:2,c:3};
console.log("a" in o);
console.log(o.hasOwnProperty("a"));
console.log(o.a != undefined);
1, in运算符
2, hasOwnProperty()
3, != undefined
//检测o对象里是否有属性a
var o={a:1,b:2,c:3};
console.log("a" in o);
console.log(o.hasOwnProperty("a"));
console.log(o.a != undefined);
转载于:https://www.cnblogs.com/pfcan66/p/8029996.html