“Array toko di LocalStorage” Kode Jawaban

JavaScript Store Array di LocalStorage

//storing array in localStorage
var colors = ["red","blue","green"];
localStorage.setItem("my_colors", JSON.stringify(colors)); //store colors
var storedColors = JSON.parse(localStorage.getItem("my_colors")); //get them back
Grepper

Array toko di LocalStorage

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

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

LocalStorage JavaScript Array

// Guardar el array en el localStorage

// El arreglo:
var array = [1, 2, 3];
// Se guarda en localStorage despues de JSON stringificarlo 
localStorage.setItem('myArray', JSON.stringify(array));

// Obtener el arreglo de localStorage

var array = localStorage.getItem('myArray');
// Se parsea para poder ser usado en js con JSON.parse :)
array = JSON.parse(array);
Pepiño

Jawaban yang mirip dengan “Array toko di LocalStorage”

Pertanyaan yang mirip dengan “Array toko di LocalStorage”

Lebih banyak jawaban terkait untuk “Array toko di LocalStorage” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya