+ 1
Javascript: "undefined" == undefined ??
var a; var b = "undefined"; alert(typeof a == b); // true Could anyone explain me why is it true? For my understanding, a is an undefined variable and b is a string with an existing value that happens to be "undefined".
2 Answers
+ 5
A typeof always returns a string, that's the reason why typeof a == b(when b is assigned a string value "undefined") is true.
And also "undefined" != undefined. "undefined" == string, while undefined == special data type.
+ 1
Infinite Thanks! That was the missing puzzle :)
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof