If variable was not defined at all, you can check this without break code execution using try-catch block as follows (you don't need to use strict
mode)
try{
notDefinedVariable;
} catch(e) {
console.log('detected: variable not exists');
}
console.log('but the code is still executed');
notDefinedVariable; // without try-catch wrapper code stops here
console.log('code execution stops. You will NOT see this message on console');
_x000D_
BONUS: (referring to other answers) Why ===
is more clear than ==
(source)