- From: Marcos Caceres <marcosc@opera.com>
- Date: Thu, 20 Aug 2009 12:49:17 +0200
- To: Scott Wilson <scott.bradley.wilson@gmail.com>
- Cc: public-webapps WG <public-webapps@w3.org>
On Thu, Aug 20, 2009 at 11:46 AM, Scott Wilson<scott.bradley.wilson@gmail.com> wrote: > The Storage [1 interface ] is defined as: > > interface Storage { > readonly attribute unsigned long length; > getter any key(in unsigned long index); > getter any getItem(in DOMString key); > setter creator void setItem(in DOMString key, in any data); > deleter void removeItem(in DOMString key); > void clear(); > }; > > I don't see any mention of accessing Storage as an array in either > WebStorage or Widgets A&E. > S > Storage is just a javascript object, so it's properties can be accessed any multiple ways: preferences.getItem(theNameOfTheKey); preferences.theNameOfTheKey preferences[preferences[0]] This makes the object that implements the interface tremendously powerful and flexible. However, I agree that WebStorage should make this more clear; but that should probably go into a primer, not in the spec. Try it out in Firefox's address bar: javascript: localStorage.setItem("test", "test123"); javascript: alert(localStorage[localStorage[0]]) javascript: alert(localStorage.test) The above will alert you "test123" -- Marcos Caceres http://datadriven.com.au
Received on Thursday, 20 August 2009 10:50:20 UTC