1//storing array in localStorage
2var colors = ["red","blue","green"];
3localStorage.setItem("my_colors", JSON.stringify(colors)); //store colors
4var storedColors = JSON.parse(localStorage.getItem("my_colors")); //get them back
1var names = [];
2names[0] = prompt("New member name?");
3localStorage.setItem("names", JSON.stringify(names));
4
5//...
6var storedNames = JSON.parse(localStorage.getItem("names"));
1// Guardar el array en el localStorage
2
3// El arreglo:
4var array = [1, 2, 3];
5// Se guarda en localStorage despues de JSON stringificarlo
6localStorage.setItem('myArray', JSON.stringify(array));
7
8// Obtener el arreglo de localStorage
9
10var array = localStorage.getItem('myArray');
11// Se parsea para poder ser usado en js con JSON.parse :)
12array = JSON.parse(array);