js判断对象中是否存在某个属性

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/AinUser/article/details/88057236

var o={x:1};

o.hasOwnProperty("x");    //true,自有属性中有x

o.hasOwnProperty("y");    //false,自有属性中不存在y

猜你喜欢

转载自blog.csdn.net/AinUser/article/details/88057236