我想检查一个对象是否有一个子对象数组
例如
{
"parent_category_id": "ABC",
"parent_category_name": "ABC COMPANY",
"place_id": 733,
"industry": {
"@nil": "true"
}
"street_id": 733
}
您将如何检查“Industry”对象是否有子数组。就像“Industry”的子数组值“@nil: true”一样。然后提醒有孩子
您可以咨询instanceof
运营商。
例如:
var t = {
"parent_category_id": "ABC",
"parent_category_name": "ABC COMPANY",
"place_id": 733,
"industry": {
"@nil": "true"
},
"street_id": 733
};
之后,您可以使用:
t.industry instanceof Object // result is: true
t.industry instanceof Array // result is: false
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句