I have a JSON Data and I would like to iterate on runStatus
, however not all the nodes have runStatus
and I am getting error that run.runStatus is Undefined
.
How can i fix the error in HTML?
[
{
"Code": "AB",
"Run": {
"Range": {
"maxValue": "75",
"minValue": "54"
},
"remarks": [],
"runStatus": "RESULTED"
}
},
{
"Code": "CD",
"Run": {
"remarks": []
}
}
]
do a check before
if(YOUR_OBJ.Run.runStatus !== undefined)
{
console.log(YOUR_OBJ.Run.runStatus);
// ...
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.