In JavaScript, the following values will cause the if
condition to fail and not execute its statement: null, undefined, false, NaN, the number 0, and the empty string ''.
Assuming that the variable jsVar is a boolean and that we want to call the proceed() method when jsVar is true, we can do the following check.
if (jsVar && jsVar == true)
proceed();
The above code snippet first check that jsVar has been defined and then checks that its value is true. The if condition will be satisfied only if both the conditions are met.
If jsVar is not a boolean then we can substitute the appropriate check in place of jsVar == true in the code above.