I have an empty array named az and when I console.log(az), it returns this:
['']
Now I want to check that if az variable returns this [''] value, go to first condition, otherwise goto 2nd condition:
if(az[0] == null){
console.log(1);
}else{
console.log(2);
}
So when I run the if..else, I get 2 meaning that az[0] is not set to null
So what's going wrong here?
How can I properly if the variable az is set to null array (['']) properly?
['']is NOT emptyundefinedandnullloosely equal(==) tonull, try usingif(!az[0])as the condition.