localStorage
is for key : value
pairs, so what you'd probably want to do is JSON.stringify
the array and store the string in the mycars
key and then you can pull it back out and JSON.parse
it. For example,
var mycars = new Array();
mycars[0] = "Saab";
mycars[1] = "Volvo";
mycars[2] = "BMW";
localStorage["mycars"] = JSON.stringify(mycars);
var cars = JSON.parse(localStorage["mycars"]);