4.6. Variables as Properties
You may have noticed by now that there are a lot of similarities in JavaScript between variables and the properties of objects. They are both assigned the same way, they are used the same way in JavaScript expressions, and so on. Is there really any fundamental difference between the variable i and the property i of an object o? The answer is no. Variables in JavaScript are fundamentally the same as object properties.
我认为作者整错了。起码
u.a = "1";
u = "1"
是不一样的。第二个u会成为全局的变量,而u.a不会
JS变量与对象属性
本文探讨了JavaScript中变量与对象属性之间的相似性和根本差异。通过示例说明了两者虽然在语法上非常相似,但在作用域和全局变量创建方面存在区别。
344

被折叠的 条评论
为什么被折叠?



