Answers for "how-to-save-array in Local storage - js"

0

how-to-save-array in Local storage - js

// our array
var movies = ["Reservoir Dogs", "Pulp Fiction", "Jackie Brown", 
"Kill Bill", "Death Proof", "Inglourious Basterds"];
 
// storing our array as a string
localStorage.setItem("quentinTarantino", JSON.stringify(movies));
 
// retrieving our data and converting it back into an array
var retrievedData = localStorage.getItem("quentinTarantino");
var movies2 = JSON.parse(retrievedData);
 
//making sure it still is an array
alert(movies2.length);
Posted by: Guest on August-19-2021

Code answers related to "how-to-save-array in Local storage - js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language