while (listItemEnumerator.moveNext()) {
    var oListItem = listItemEnumerator.get_current();

sessionStorage.setItem('Title', listTitle);
sessionStorage.setItem('Url', listUrl);
sessionStorage.setItem('IsActive', listIsActive);
sessionStorage.setItem('Order', listOrder);

Here is my code for adding an array to sessionstorage. When outputting the array from session storage it seems to output a letter at a time but when I output the array without session storage it outputs the whole valu

  • How are you outputting from session storage? – Aanchal Jun 26 '14 at 12:26
  • sessionStorage.Title[i] – bimbob Jun 26 '14 at 12:27

Session storage saves everything in string format. In order to use session storage with our array, we'll need to convert our array into a string using a method that makes it easy for us to unconvert later. The way convert an array into a string is by using the JSON stringify function.

Check following example:

var movies = ["Reservoir Dogs", "Pulp Fiction", "Jackie Brown", 
              "Kill Bill", "Death Proof", "Inglourious Basterds"];

localStorage.setItem("quentinTarantino", JSON.stringify(movies));

To retrieve:

var retrievedData = localStorage.getItem("quentinTarantino");
var movies2 = JSON.parse(retrievedData);


| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.