Answers for "js store in localstorage"

28

Javascript store in localStorage

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
2

localStorage in javascript

// 'key' could be any variable to address your 'value'. 
//'value' could be of any data-type.

// Save data to localStorage
localStorage.setItem('key', JSON.stringify('value'));

// Get saved data from localStorage
localStorage.getItem('key') ? JSON.parse(localStorage.getItem('key') : '';

// Remove saved data from localStorage
localStorage.removeItem('key');

// Remove all saved data from localStorage
localStorage.clear();
Posted by: Guest on October-09-2021
0

my local storage

/* function for setIetm to local storage */

function set(){
    var sendJson = JSON.stringify(allwish);
    localStorage.setItem("wishKay",sendJson);
}
Posted by: Guest on October-05-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language