“LocalStorage JavaScript” Respostas de código

JavaScript Store em 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
Grepper

Salvar no armazenamento local

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

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

localStorage.removeItem('myCat');

// Clear all items
localStorage.clear();
Tame Toucan

JavaScript de armazenamento local

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';
DCmax1k

LocalStorage JavaScript

localStorage.setItem('user_name', 'Rohit'); //store a key/value
var retrievedUsername = localStorage.getItem('user_name'); //retrieve the key
Grepper

JS LocalStorage

> Add item
localStorage.setItem('foo', 'bar');
> Get item
localStorage.getItem('foo');
> Remote item
localStorage.removeItem('foo');
> Clear all
localStorage.clear();
Code Cat

LocalStorage JavaScript

localStorage.setItem(key, val);
var val = localStorage.getItem(key);
localStorage.removeItem(key);
localStorage.clear();
Successful Sandpiper

Respostas semelhantes a “LocalStorage JavaScript”

Perguntas semelhantes a “LocalStorage JavaScript”

Mais respostas relacionadas para “LocalStorage JavaScript” em JavaScript

Procure respostas de código populares por idioma

Procurar outros idiomas de código