Ian Hickson wrote:
On Wed, 29 Apr 2009, John J Barton wrote:
  
Ian Hickson wrote:

 On Thu, 30 Apr 2009, Sean Hogan wrote:
  

 sessionStore[2] = "howdy";
print(sessionStore[2]); // prints null?
print(sessionStore["2"]); // prints "howdy"

To my knowledge that's not consistent with any other object or interface 
in the browser.
    

 Unless I'm mistaken, they both print "howdy".

  

But earlier you said:

 >   for(var i = 0; i < sesssionStore.length; i++) foo(i, sessionStore[i]);
 
gives:

 (0, "2").

I don't think both of these can be true.
    

Why not?
  
Because developers will be outraged if they get keys sometimes and values other times.  Consider:

window.addEventListener('load', function(event){
    sessionStorage["a"] = "letter";
    sessionStorage["1"] = "number";
    sessionStorage["first"] = "ordinal";
    var str = "";
    try
    {
        for (var i = 0; i < sessionStorage.length; i++)
            str += "keys["+i+"]="+sessionStorage[i]+"\n";

        document.getElementById("result").innerHTML=str;
    }
    catch(exc)
    {
        document.getElementById("result").innerHTML=exc;
    }
}, true);

As I understand your proposal, the correct result would be
keys[0]=a
keys[1]=number  <<< !!! wait it's a value!
keys[2]=first
I think this is unreasonable and I would expect browser would not agree to implement an API certain to lead to bug reports.

BTW FF 3.5 says: keys[0]=undefined keys[1]=number keys[2]=undefined. That is a reasonable answer. This also demonstrates why the length property is not useful: you can't use it in any sensible statements.

If you want to iterate the keys, no problem, change the API:

var keys = sessionStorage.getKeys();  // array of keys with |length|.

jjb