Looking at this code; why doesn't a satisfy (a === typeof a)
var a;
(a === undefined)?console.log("a is undefined"):null;
(typeof a === 'undefined')?console.log("typeof a is 'undefined'"):null;
Looking at this code; why doesn't a satisfy (a === typeof a)
var a;
(a === undefined)?console.log("a is undefined"):null;
(typeof a === 'undefined')?console.log("typeof a is 'undefined'"):null;
According to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof typeof
always returns a string.
Because:
One is a string with the string value
'undefined'
, one is theundefined
primitive. Those two are not the same.typeof x
always returns string values such as"undefined"
,"boolean"
,"string"
,"object"
, etc....