To check for null, undefined, or blank variables in JavaScript you can use typeof method below is the code for that:-:-
if( typeof foo !== 'undefined' ) {
// foo could get resolved and it's defined
}
If you can be sure that a variable is declared at least, you should directly check if it has a truth value like shown above.
The above method will cover cases where the value was never defined, and also any of these:
null
Undefined
0
empty string
false
NaN