“Cara Menyimpan Objek di LocalStorage” Kode Jawaban

Menyimpan objek di HTML5 LocalStorage

var testObject = { 'one': 1, 'two': 2, 'three': 3 };

// Put the object into storage
localStorage.setItem('testObject', JSON.stringify(testObject));

// Retrieve the object from storage
var retrievedObject = localStorage.getItem('testObject');

console.log('retrievedObject: ', JSON.parse(retrievedObject));
Mobile Star

Cara Menyimpan Objek di LocalStorage

var testObject = { 'one': 1, 'two': 2, 'three': 3 };

// Put the object into storage
localStorage.setItem('testObject', JSON.stringify(testObject));

// Retrieve the object from storage
var retrievedObject = localStorage.getItem('testObject');

console.log('retrievedObject: ', JSON.parse(retrievedObject));
Mobile Star

objek toko javascript di penyimpanan lokal

var person = { "name": "billy", "age": 23};

localStorage.setItem('person', JSON.stringify(person)); //stringify object and store
var retrievedPerson = JSON.parse(localStorage.getItem('person')); //retrieve the object
Grepper

Jawaban yang mirip dengan “Cara Menyimpan Objek di LocalStorage”

Pertanyaan yang mirip dengan “Cara Menyimpan Objek di LocalStorage”

Lebih banyak jawaban terkait untuk “Cara Menyimpan Objek di LocalStorage” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya