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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:06:20+00:00 2026-06-03T01:06:20+00:00

Does anyone know, if it’s possible to make a local storage with multiple objects

  • 0

Does anyone know, if it’s possible to make a local storage with multiple objects in it when I’m doing a loop in javascript?

At the moment my code looks like this:

var albums = '';
var album_list = '';

$.each(data, function(i,item){
   var name = item.name;
   albums += '<li>'+item.name+'</li>';

   var album_content = {name: item.name, uid: 1};
   var album_content = album_content+',';

   album_list += album_content;


});

var album_list = '['+album_list+']';   
localStorage.setItem("albums", JSON.stringify(album_list));
var albums_l = JSON.parse(localStorage.getItem("albums"));

$.each(albums_l, function(i,item){
   console.log(item.name);
});

But that gives me an error.
Anyone have a better solution for this, so I just have one localstorage and all the data in that?

  • 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-03T01:06:21+00:00Added an answer on June 3, 2026 at 1:06 am

    You’re mixing objects and strings in your code. Your album_content is initialized in the loop as an object ({name: item.name, uid: 1}). In the very next line you treat it as a string by appending a comma.

    Overall use an array to collect all your objects. It’s (almost) always better to use the native objects instead of trying to emulate them in some way.

    Try this code instead.

    var albums = '';
    var album_list = [];
    
    $.each(data, function(i,item){
       var name = item.name;
       albums += '<li>'+item.name+'</li>';
    
       var album_content = {name: item.name, uid: 1};
       // remove that line completly
       // var album_content = album_content+',';
    
       album_list.push( album_content );
    
    });
    
    
    localStorage.setItem("albums", JSON.stringify( album_list ));
    var albums_l = JSON.parse(localStorage.getItem("albums"));
    
    $.each(albums_l, function(i,item){
       console.log(item.name);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know how to make this code stop the knob from rotating past
Does anyone know where code can be found for Metaphone 3 matching for T-SQL
Does anyone know how to make x-axis and y-axis look a bit bolder or
Does anyone know why 2 /// 2 is 2 in Javascript? What is this
Does anyone know what's wrong with this code? Cipher cipher = Cipher.getInstance(AES/ECB128/PKCS5Padding, SunJCE); Algorithm:
does anyone know howto programmatically show and make the field editable for tracking number
Does anyone know why this bean is getting instantiated multiple times? I only ever
Does anyone know of any existing solutions using javascript that can parse a crontab
Does anyone know if it's possible to create a listener to detect when a
Does anyone know what CSS and JavaScript API the Gmail mobile app uses? It

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.