I was working on a chrome extension where I wanted to store javascript objects in localstorage and retrieve it later. But I was unable to do so with just setting the javascript objects in localstorage. I had to first stringify it and then parse it.
//create a javascript object array. var team = [{lead:'Monica',projectManager:'Ross',intern:'Chandler'}, {lead:'Joey',projectManager:'Rachel',intern:'Phoebe'}]; //Store it in the localstorage and name it localStr. localStorage.setItem('localStr',JSON.stringify(team)); //Retrieve the data and parse it back to JSON. var retrieveData = JSON.parse(localStorage.getItem('localStr')); //Write the data to the console. console.log('and the lead of team 1 is '+ retrieveData[0].lead);