Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8051373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:17:17+00:00 2026-06-05T07:17:17+00:00

I tried what made sense: In the module below localStorage.foo works but localStorage.session_array[‘privacy’] returns

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:17:18+00:00Added an answer on June 5, 2026 at 7:17 am

    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.

    // Store 'marcus' at 'username'
    store.set('username', 'marcus')
    
    // Get 'username'
    store.get('username')
    
    // Remove 'username'
    store.remove('username')
    
    // Clear all keys
    store.clear()
    
    // Store an object literal - store.js uses JSON.stringify under the hood
    store.set('user', { name: 'marcus', likes: 'javascript' })
    
    // Get the stored object - store.js uses JSON.parse under the hood
    var user = store.get('user')
    alert(user.name + ' likes ' + user.likes)
    
    store.set('user', { name: 'marcus', likes: 'javascript' })
    alert("Hi my name is " + store.get('user').name + "!")
    
    store.set('tags', ['javascript', 'localStorage', 'store.js'])
    alert("We've got " + store.get('tags').length + " tags here")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made multi-language unicode files and tried to use it in my app, but
I tried to made it as simple I could. I wonder me about a
So i made this simple JApplet and tried to open a socket and write
I've made the same mistake many times: I've tried to use a Stream that
I made two different Fibonacci functions, the first one worked perfectly. Then I tried
When I tried to focus on compiler in code, I made break point on
Tried to use what's here , but that doesn't solve things for me. I've
Tried various avenues but no luck. I am using a MBP with 10.7.4. I
I'm using Xcode version 3.2.2 but the tutorial at this site was made for
I'm fairly new to ggplot. I have made a bumpplot using code posted below.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.