check undefined in JavaScript

You can use typeof, like this:

if (typeof something != "undefined") {
    // ...
}
if (typeof myVar !== "undefined") {
    function_call();
}


Leave a Reply