为什么我不能在Firefox Web控制台中更改`name`的类型? [英] Why can't I change the type of `name` in Firefox web console?
本文介绍了为什么我不能在Firefox Web控制台中更改`name`的类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Firefox Web控制台中,为什么我可以更改name2
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"
,而不是name
typeof name
"string"
name=12
12
typeof name
"string"
?
推荐答案
由于它是全局对象的只读属性(感谢Pointy),因此JavaScript明确将其强制转换为字符串.
It's explicitly being cast to a string by JavaScript, since it's a readonly property of the global object (thanks Pointy).
这篇关于为什么我不能在Firefox Web控制台中更改`name`的类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文