Re: Property enumeration for NodeList, etc.

On 6/17/11 5:35 PM, David Flanagan wrote:
>>    3. No further own properties or properties from the object’s
>>       prototype chain are enumerated.
>
> Is point 3 for real? If I get a NodeList like document.childNodes and
> use it in a for/in loop, I'll just get the index elements and not the
> enumerable inherited length and item? And if I add an enumerable expando
> property to that NodeList, it won't be enumerated either?

For what it's worth, point 3 does not match the behavior of Chrome, 
Safari, Gecko, or Opera.

I don't have IE on hand to test right now.

> Is there any precedent for this? What other objects behave this way?

Array objects in JS, from an author perspective, but that's due to the 
various Array.prototype stuff and the length property not being 
enumerable.  Expandos are obviously enumerated for arrays.

-Boris

Received on Saturday, 18 June 2011 04:43:33 UTC