W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2009

Re: Storage 'length' and enumeration

From: Ian Hickson <ian@hixie.ch>
Date: Wed, 29 Apr 2009 18:38:17 +0000 (UTC)
To: "John J. Barton" <johnjbarton@johnjbarton.com>
Cc: public-webapps@w3.org
Message-ID: <Pine.LNX.4.62.0904291835140.12381@hixie.dreamhostps.com>
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 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:31 GMT