Why can't I change the type of `name` in Firefox web console? [duplicate]

雨燕双飞 提交于 2019-12-13 10:15:15

问题


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"

?


回答1:


It's explicitly being cast to a string by JavaScript, since it's a readonly property of the global object (thanks Pointy).



来源:https://stackoverflow.com/questions/56086438/why-cant-i-change-the-type-of-name-in-firefox-web-console

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!