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 4027676
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:07:34+00:00 2026-05-20T11:07:34+00:00

For example I have the following code: localStorage[screenshots] = new Array(); localStorage[screenshots][a] = 9;

  • 0

For example I have the following code:

  localStorage["screenshots"] = new Array();
  localStorage["screenshots"]["a"] = 9;
  alert(localStorage["screenshots"]["a"]);

  Arr = new Array();
  Arr["screenshots"] = new Array();
  Arr["screenshots"]["a"] = 9;
  alert(Arr["screenshots"]["a"]);

(I use Google Chrome v9.0.597.107 on Windows Vista 32-bit)

But only the second part works (output of alert() is “a”)!
The first alert outputs in contrast “undefined”!

What is the problem?

Thanks.

  • 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-05-20T11:07:35+00:00Added an answer on May 20, 2026 at 11:07 am

    localStorage stores values as strings, so you need to JSON serialize your objects on the way in and deserialize them on the way out. For example:

    var data = {'A': 9};
    
    localStorage['screenshots'] = JSON.stringify(data);
    
    // Later/elsewhere:
    
    var data = JSON.parse(localStorage['screenshots']);
    
    // 9
    console.log(data.A);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code example to use an object that receives the action
I have the following example code: class A(object): def __init__(self, id): self.myid = id
Given the following example, why do I have to explicitly use the statement b->A::DoSomething()
I have the following code example below. Whereby you can enter a command to
I have the following code: $.get('http://www.example.org', {a:1,b:2,c:3}, function(xml) {}, 'xml'); Is there a way
I have the following code: <ul id=myList> <li class=li1>Example 1</li> <li class=li2>Example 2</li> <li
For example I have following jQuery code: var div1 = $(divs).next(); How do I
Say for example I have the following code: <h3>My very long title</h3> <h3>Another long
I have following code (php), it will match img-src and replace with new url
I have the following code (example), and I'm really not comfortable with so many

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.