Answers for "localstorage.setitem object"

10

Storing Objects in 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));
Posted by: Guest on February-01-2020
28

local storage javascript object

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
Posted by: Guest on July-22-2019
5

save to local storage

localStorage.setItem('myCat', 'Tom');

var cat = localStorage.getItem('myCat');

localStorage.removeItem('myCat');

// Clear all items
localStorage.clear();
Posted by: Guest on April-27-2020
1

localstorage set item

localStorage.getItem('data')
localStorage.setItem('token', 'token here');
localStorage.removeItem('token');
Posted by: Guest on March-06-2021
2

localstorage setitem

function populateStorage() {
  localStorage.setItem('bgcolor', 'red');
  localStorage.setItem('font', 'Helvetica');
  localStorage.setItem('image', 'myCat.png');
}
Posted by: Guest on January-28-2021

Code answers related to "localstorage.setitem object"

Code answers related to "Javascript"

Browse Popular Code Answers by Language