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;
On
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 theundefinedprimitive. Those two are not the same.typeof xalways returns string values such as"undefined","boolean","string","object", etc....