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.
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
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
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
See also generalized discussion of expando properties on StackOverflow here.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…