We are frequently using the following code pattern in our JavaScript code
if (typeof(some_variable) != \'undefined\' && some_variable != null) {
Similar to what you have, you could do something like
if (some_variable === undefined || some_variable === null) { do stuff }