I found this weird problem, when I write Javascript code like below:
var name = 1;
alert(typeof name); // this will alert "string"
var b = 1;
alert(typeof b); // this will alert "number"
I got "string" for "typeof name", but got "number" for "typeof b", however, I think they both should be "number"
And this code won't run either:
var name = 1;
if (name === 1) {
alert("ok")
}
It won't alert out, since name's type is "string" !
I tested above code in Chrome and Safari, they both give the same result, so why "typeof name" is "string" in this case? why the variable name "name" is so special?