Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

localstorage save array

var names = [];
names[0] = prompt("New member name?");
localStorage.setItem("names", JSON.stringify(names));

//...
var storedNames = JSON.parse(localStorage.getItem("names"));
Comment

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);
Comment

PREVIOUS NEXT
Code Example
Javascript :: window is not defined Next Js 
Javascript :: settimeout in vuejs 
Javascript :: React does not recognize the `activeClassName` prop on a DOM element 
Javascript :: how to import your external js 
Javascript :: js listen for class change event 
Javascript :: Binary Agents 
Javascript :: javascript form submit on button click check if required fields not empty 
Javascript :: how to get the url of a page in javascript 
Javascript :: jsconfig.json 
Javascript :: javascript format rupiah 
Javascript :: get number from string using jquery 
Javascript :: jquery format date 
Javascript :: jquery get element max height 
Javascript :: javascript insert item into array 
Javascript :: default input type date limit date js 
Javascript :: Vuejs trigger function on route change 
Javascript :: javascript compare arrays remove duplicates 
Javascript :: using aria attributes in angular 
Javascript :: javascript append to array 
Javascript :: how to check if window is loaded javascript 
Javascript :: jest mock react-redux hooks 
Javascript :: onclick on non button 
Javascript :: javascript infinite parameters 
Javascript :: two digit js' 
Javascript :: how to use static files in express with ejs 
Javascript :: js remove item from array by value 
Javascript :: any click event jquery 
Javascript :: react history go back 
Javascript :: videojs cdn 
Javascript :: javascript cahnge colour of strokerect 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =