Answers for "using localstorage js"

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
23

local storage javascript

function createItem() {
	localStorage.setItem('nameOfItem', 'value'); 
} 
createItem() // Creates a item named 'nameOfItem' and stores a value of 'value'

function getValue() {
	return localStorage.getItem('nameOfItem');  
} // Gets the value of 'nameOfItem' and returns it
console.log(getValue()); //'value';
Posted by: Guest on April-26-2020
3

localstorage

window.localStorage.setItem('myCat', 'Tom');
const cat = window.localStorage.getItem('myCat');
Posted by: Guest on March-12-2021
0

how to get variable in local storage in javascript

localStorage.getItem('id');
Posted by: Guest on February-28-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language