Re: Move length property to the set of supported property indicies?

On 5/20/11 6:56 PM, David Flanagan wrote:
> I suspect that authors would expect the length property to behave just
> like the array index properties with which it is intimately related.

It doesn't behave like them in browsers now, though (e.g. it's never 
dynamically created or destroyed).

> Conceptually, because length just seems to go with the array index
> properties.

I'm not sure I agree, but...

>  From an implementation standpoint, once I have a proxy that handles the
> array index properties, I can implement item(n) like this without having
> to use a WeakMap:
>
> NodeList.prototype.item = function(n) { r = this[n]; if (r===undefined)
> return null; else return r; };

This implementation is incorrect, for what it's worth, in all sorts of 
ways, but I expect you knew that...

With enough error-checking on n, I guess this could work.  How are you 
planning to do HTMLCollection?

-Boris

Received on Friday, 20 May 2011 23:13:21 UTC