I have Dynamic AJAX JSON Response object Data variable
var Data = {"categories":
[
{"Id":"2","CategoryName":"Womens"},
{"Id":"3","CategoryName":"Mens"},{"Id":"4","CategoryName":"Kids"},
{"Id":"5","CategoryName":"Home"},{"Id":"6","CategoryName":"Health and Beauty"},
{"Id":"7","CategoryName":"Seasonal Events"},{"Id":"10","CategoryName":"Model Shots"},
{"Id":"11","CategoryName":"Product Shots"},
{"Id":"12","CategoryName":"Accessories"},
{"Id":"13","CategoryName":"Tops"},{"Id":"14","CategoryName":"Spuds"},
{"Id":"15","CategoryName":"EVIAN"}
],
"brands_cat":{
"_bandCount":{"171": "BrandId" : "171", "ArchiveName": "HP",
"img_from_archive":"7"}
}
}
};
When i used in loop and check undefined, works fine
for(var i in Data.categories){
if(typeof Data.categories[i] == 'undefined'){
alert(i+"Cat undefined");
}
}
But when i used typeof to check undefined,
for(var i in Data.categories){
if(typeof Data.brands_cat._catCount[i].total == 'undefined'){
alert(i+"Cat total undefined");
}
}
And it gave error
TypeError: Data.brands_cat._catCount is undefined
Is it possible to check multilevel JSON object undefined with typeof keyword