Bruce Gust
asked on
How to check for both undefined and NULL?
Here's my attempt to troubleshoot a problem that I have yet to completely track down...
But I'm getting closer!
This is what I get back:
you've got some JSON
null
So, I've got some JSON, but when I try to see it, I get NULL.
I'm thinking I need a better IF statement, but how?
How do I check for both "undefined" and NULL?
I tried this and it didn't work: if(typeof json !=='undefined' || json !== NULL) {
But I'm getting closer!
if(typeof json !=='undefined') {
console.log("you've got some JSON");
console.log(json);
console.log(json.chartData);
if (json.chartData) {
buildChart(json.chartData);
}
}
else {
console.log("no json data");
}
This is what I get back:
you've got some JSON
null
So, I've got some JSON, but when I try to see it, I get NULL.
I'm thinking I need a better IF statement, but how?
How do I check for both "undefined" and NULL?
I tried this and it didn't work: if(typeof json !=='undefined' || json !== NULL) {
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER