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

saving an array to localstorage

import { LocalService } from './../../../app/local.service'; <--your local service file

constructor(private local: LocalService)

this.yourArray.forEach(p => this.local.save(p));
Comment

PREVIOUS NEXT
Code Example
Javascript :: validatorjs get all errors 
Javascript :: javascript queryselector starts with 
Javascript :: drupal 8 get node from path alias 
Javascript :: js decode base64 
Javascript :: invalid geojson object leaflet 
Javascript :: how to right rotate an array in JS 
Javascript :: javascript thousand separator 
Javascript :: pass data navigate react router dom 
Javascript :: set a previous year to the current date in javascript 
Javascript :: httpget javascript 
Javascript :: javascript sort object by key 
Javascript :: javascript number methods 
Javascript :: write json file nodejs 
Javascript :: react-native android 
Javascript :: what is niceScroll 
Javascript :: iframe player youtube onfinish event 
Javascript :: function use for placing bet 
Javascript :: How to fix stomp websocket error 
Javascript :: calling javascript functions from unity scripts 
Javascript :: js cypress div text 
Javascript :: discord.js random message 
Javascript :: javascript fill array 
Javascript :: generate a sequence numbers between a range javascript 
Javascript :: number validation in javascript 
Javascript :: react js empty build 
Javascript :: javascript maximum date 
Javascript :: javascript remove last character in a string 
Javascript :: parse int into 2 digits format javascript 
Javascript :: call javascript function after div load 
Javascript :: firebase storage javascript delete document 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =