JavaScript:Expando 属性是什么? [英] JavaScript: What is the Expando Property?
问题描述
我在阅读 JavaScript 内存泄漏时遇到了这个属性.我被告知此属性仅在 Internet Explorer 中受支持,并负责循环引用.
I came across this property while reading about JavaScript memory leaks. I was informed that this property is supported only in Internet Explorer and is responsible for circular reference.
我尝试检查并发现此属性在任何浏览器中都不可用.任何人都可以提供有关此属性的任何见解以及它与内存泄漏的关系吗?
I tried to check and found this property not available in any of the browsers. Can anyone offer any insight on this property and how is it linked to memory leaks?
推荐答案
我带着同样的问题来到这里,也是在阅读了一篇关于内存泄漏的文章后.阅读这里的答案后,我仍然感到困惑,所以我想我会在进行更多研究后分享我的发现.
I came here with the same question, also after reading an article about memory leaks. I was still confused after reading the answers here, so I thought I'd share my findings after some more research.
在 JavaScript 中要知道诸如 .expandoProperty
之类的东西是否是语言的一部分,或者是否有人对属性名称很聪明,这可能会令人困惑.
It can be confusing in JavaScript to know if something like .expandoProperty
is part of the language or somebody being clever with property names.
obj.expandoProperty
也可以是 obj.foo
.他们试图通过使用.expandoProperty"来表达的一点是该属性最初并不作为对象的一部分存在.
obj.expandoProperty
in the memory leak article could just as well have been obj.foo
. The point they are trying to get across by using ".expandoProperty" is that the property did not exist as part of the object originally.
var obj = {myProp: ''};
obj.myProp = 'foo'; //myProp is not an expando property
obj.myNewProp = 'bar'; //myNewProp is an expando property
添加到组合中:.expando
是一个仅限 IE 的属性,它设置或检索指示是否可以在对象内创建任意变量的值".MSDN 文章
Add to the mix: .expando
is an IE-only property that "sets or retrieves a value indicating whether arbitrary variables can be created within the object." MSDN article
另请参阅此处对 StackOverflow 上的 expando 属性的一般性讨论.
这篇关于JavaScript:Expando 属性是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!