var someArray = [1, 2, 3, 4, 5]; localStorage.setItem('mydata', JSON.stringify(someArray));
var data = []; if (localStorage.getItem('mydata')) { data = JSON.parse(localStorage.getItem('mydata')); }