This is an oddity I've seen occasionally in JS - maybe someone can shed light on it.
I do a test for undefined on a variable:
if (x !== 'undefined'){}
or even
if (typeof x !== 'undefined'){}
And the browser still throws an error:
ReferenceError: x is not defined
Even
if (x) {}
throws the error.
This is a framework-level global variable I am checking for, so possibly something to do with different scopes. (No critiques of global variables - again, its the existence of a framework I'm testing for).
typeof x !== 'undefined'
should not throw a ReferenceError.typeof x
for anyx
.