“LocalStorage API” Respostas de código

Salvar no armazenamento local

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

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

localStorage.removeItem('myCat');

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

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

// localStorage for objects, arrays or any data type
var obj = {
	firstName: "Bob",
    lastName: "Jeff",
    age: 13
}
localStorage.setItem("itemname", JSON.stringify(obj)); // Save the obj as string
var item = JSON.parse(localStorage.getItem("itemname")); 
// ^^ Parse string then set `item` as the obj
sunst0rm

JavaScript LocalStorage

localStorage.setItem("user_name", "Bob");

document.body.addEventListener("click", function(){
  alert(localStorage.getItem("user_name"))
});
Breakable Baboon

LocalStorage JS

// Set
localStorage.setItem('monChat', 'Tom');

// Get
localStorage.getItem('myCat');

// Remove
localStorage.removeItem('myCat');
Lively Leopard

LocalStorage API

localStorage //to see localStorage data
localStorage.clear() // to clear all the localStorage data
localStorage.setItem("something") // to set a localStorage Item
localStorage.getItem("something") //to read the localStorage data
localStorage.removeItem("something") // to remove the localStorage data
Disturbed Dingo

Respostas semelhantes a “LocalStorage API”

Perguntas semelhantes a “LocalStorage API”

Mais respostas relacionadas para “LocalStorage API” em JavaScript

Procure respostas de código populares por idioma

Procurar outros idiomas de código