In Firefox web console, why can I change the type of name2
var name2=12
undefined
typeof name2
"number"
name2="hello"
"hello"
typeof name2
"string"
and not for name
typeof name
"string"
name=12
12
typeof name
"string"
?
In Firefox web console, why can I change the type of name2
var name2=12
undefined
typeof name2
"number"
name2="hello"
"hello"
typeof name2
"string"
and not for name
typeof name
"string"
name=12
12
typeof name
"string"
?
It's explicitly being cast to a string by JavaScript, since it's a readonly property of the global object (thanks Pointy).