js判断对象里面是否有某个属性

版权声明: https://blog.csdn.net/Liuboxx1/article/details/81774557
if(obj.hasOwnProperty('property')) {
    console.log('属性存在');
}else {
    console.log('属性不存在');
}

猜你喜欢

转载自blog.csdn.net/Liuboxx1/article/details/81774557
今日推荐