JavaScript:什么是Expando属性? [英] JavaScript: What is the Expando Property?

查看:63
本文介绍了JavaScript:什么是Expando属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在阅读有关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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆