Re: Storage 'length' and enumeration

On Wed, 29 Apr 2009, John J. Barton wrote:
> 
> I reiterate my criticism: using a length property in this type is 
> inconsistent with Javascript and with developers expectations about 
> objects. Every time we use this object we will make pointless mistakes 
> because the type mimics arrays only partially and we won't be able to 
> recall which part it imitates. A simple change from |length| to a method 
> call like getNumberOfItems() would prevent this co-incidental mimicry 
> and make the standard better.

The Storage object works like an HTMLCollection object except that you can 
also add items, and except that indexing by number returns the key, not 
the value, since otherwise there'd be no way to know which keys were being 
returned. I agree that it's not like an Array, but just having a "length" 
property doesn't mean it works like an Array -- there are lots of host 
objects in the DOM with "length" properties.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Wednesday, 29 April 2009 18:55:04 UTC