Check out example codes for "Storing Objects in HTML5 localStorage". It will help you in understanding the concepts better.

Code Example 1

var testObject = { 'one': 1, 'two': 2, 'three': 3 };  // Put the object into storage localStorage.setItem('testObject', JSON.stringify(testObject));  // Retrieve the object from storage var retrievedObject = localStorage.getItem('testObject');  console.log('retrievedObject: ', JSON.parse(retrievedObject));

Code Example 2

var person = { "name": "billy", "age": 23};    localStorage.setItem('person', JSON.stringify(person)); //stringify object and store  var retrievedPerson = JSON.parse(localStorage.getItem('person')); //retrieve the object

Code Example 3

var testObject = { 'one': 1, 'two': 2, 'three': 3 };  // Put the object into storage localStorage.setItem('testObject', JSON.stringify(testObject));  // Retrieve the object from storage var retrievedObject = localStorage.getItem('testObject');  console.log('retrievedObject: ', JSON.parse(retrievedObject));

Code Example 4

var testObject = { 'one': 1, 'two': 2, 'three': 3 };  // Put the object into storage localStorage.setItem('testObject', JSON.stringify(testObject));  // Retrieve the object from storage var retrievedObject = localStorage.getItem('testObject');  console.log('retrievedObject: ', JSON.parse(retrievedObject));

Learn ReactJs, React Native from akashmittal.com