I tried what made sense:
In the module below localStorage.foo works but localStorage.session_array['privacy'] returns undefined.
This is prototype code for modern broswsers.
var ISession = ( function ()
{
localStorage.session_array =
{
privacy: 0
};
localStorage.foo = 1;
var SessionI = function ( )
{
};
SessionI.prototype.get = function( type )
{
return localStorage.session_array[ type ];
};
SessionI.prototype.set = function( type, value )
{
localStorage.session_array[ type ] = value;
alert( '|' + localStorage.foo ); // returns 1
alert( '|' + localStorage.session_array[ 'privacy' ] ); // returns undefined
};
return SessionI;
} ) ();
In the mean while I’m just going to implement this using non array properties.
Since localstorage isnt supported by all browsers, you might want to look at store.js instead. It has support for localstorage when available and if not uses some other storage mechanisms (globalStorage and UserData). The best part is you can also store JSON encoded data as well.