I have some JSON data like below:
{
"errorCode": null,
"message": "Success",
"result": {
},
"totalRecord": 0,
"checkAccess": true,
"token": "fb8904acf4dbf0406ac3fd16acd9b84807d2a0e2913aecc3f39e90ca4b53161af6058ca5ee46b9877b75292e5ca9b8df969a325fa3b40c0e4acde546a431f55f6c07de8a854b9e0bf6aeba314d239267"
}
In the JSON you can find the "result"
is empty, but how can I identify it by if statement? I tried to use !== "undedined"
and !==null
but the statment still executes.
if(trend1_data[0].result !== 'undefined'){
var resultone = trend1_data[0].result;
var chartVal1 = resultone.mention30d.chartValues;
for(var i=0; i < chartVal1.length; i++){
vol1.push(chartVal1[i].value);//a for loop to generate value array
Xvol1.push(chartVal1[i].date);// for xaris values e.g:date
}
}